@openhps/core
Version:
Open Hybrid Positioning System - Core component
75 lines • 2.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Relative3DPosition = void 0;
const tslib_1 = require("tslib");
const utils_1 = require("../../utils");
const decorators_1 = require("../decorators");
const Relative2DPosition_1 = require("./Relative2DPosition");
/**
* Relative 3D Position relative to another object. This indicates the translation
* relative to another reference object.
*/
let Relative3DPosition = class Relative3DPosition extends Relative2DPosition_1.Relative2DPosition {
constructor(referenceObject, x, y, z, unit = utils_1.LengthUnit.METER) {
super(referenceObject, x, y, unit);
this.referenceValue.z = z ? z : 0;
}
get z() {
if (!this.referenceValue) {
return undefined;
}
return this.referenceValue.z;
}
set z(value) {
if (!this.referenceValue) {
return;
}
this.referenceValue.z = value;
}
fromVector(vector, unit) {
var _a, _b;
if (unit) {
this.x = unit.convert(vector.x, this.unit);
this.y = unit.convert(vector.y, this.unit);
this.z = unit.convert((_a = vector.z) !== null && _a !== void 0 ? _a : 0, this.unit);
}
else {
this.x = vector.x;
this.y = vector.y;
this.z = (_b = vector.z) !== null && _b !== void 0 ? _b : 0;
}
return this;
}
toVector3(unit) {
if (unit) {
return new utils_1.Vector3(this.unit.convert(this.x, unit), this.unit.convert(this.y, unit), this.unit.convert(this.z, unit));
}
else {
return new utils_1.Vector3(this.x, this.y, this.z);
}
}
/**
* Clone the position
* @returns {Absolute3DPosition} Cloned position
*/
clone() {
const position = super.clone();
position.x = this.x;
position.y = this.y;
position.z = this.z;
return position;
}
};
exports.Relative3DPosition = Relative3DPosition;
tslib_1.__decorate([
(0, decorators_1.SerializableMember)({
numberType: decorators_1.NumberType.DECIMAL,
}),
tslib_1.__metadata("design:type", Number),
tslib_1.__metadata("design:paramtypes", [Number])
], Relative3DPosition.prototype, "z", null);
exports.Relative3DPosition = Relative3DPosition = tslib_1.__decorate([
(0, decorators_1.SerializableObject)(),
tslib_1.__metadata("design:paramtypes", [Object, Number, Number, Number, utils_1.LengthUnit])
], Relative3DPosition);
//# sourceMappingURL=Relative3DPosition.js.map