| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- class position {
- #x;
- #y;
- #z;
- constructor(x = 0, y = 0, z = 0) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- set x(target) {
- if (typeof(target) !== "number") {
- throw new TypeError("X cord must be an number.");
- }
- this.#x = target;
- }
- set y(target) {
- if (typeof(target) !== "number") {
- throw new TypeError("Y cord must be an number.");
- }
- this.#y = target;
- }
-
- set z(target) {
- if (typeof(target) !== "number") {
- throw new TypeError("Z cord must be an number.");
- }
- this.#z = target;
- }
- get x() {
- return this.#x;
- }
- get y() {
- return this.#y;
- }
- get z() {
- return this.#z;
- }
- compare(target) {
- if (!(target instanceof position)) {
- throw new TypeError("Can only compare position with position.");
- }
- const result = new position();
- result.x = target.x - this.x;
- result.y = target.y - this.y;
- result.z = target.z - this.z;
- return result;
- }
- }
- export { position };
|