@openhps/core
Version:
Open Hybrid Positioning System - Core component
38 lines • 1.3 kB
JavaScript
import { __decorate, __metadata } from "tslib";
import { Orientation } from './Orientation';
import { AngleUnit } from '../../utils';
import { SerializableObject } from '../decorators';
import { RelativePosition } from './RelativePosition';
/**
* Relative orientation relative to another object. This indicates the rotation
* relative to another reference object.
*/
let RelativeOrientation = class RelativeOrientation extends RelativePosition {
constructor(referenceObject, orientation) {
super(referenceObject, orientation, AngleUnit.DEGREE);
}
/**
* Orientation accuracy
* @returns {Accuracy} Position accuracy
*/
get accuracy() {
return this.referenceValue.accuracy;
}
set accuracy(value) {
if (!value) {
throw new Error(`Accuracy can not be undefined!`);
}
this.referenceValue.accuracy = value;
}
static fromQuaternion(quat) {
return new Orientation(quat.x, quat.y, quat.z, quat.w);
}
clone() {
const vector = super.clone();
vector.accuracy = this.accuracy ? this.accuracy.clone() : undefined;
vector.timestamp = this.timestamp;
return vector;
}
};
RelativeOrientation = __decorate([SerializableObject(), __metadata("design:paramtypes", [Object, Orientation])], RelativeOrientation);
export { RelativeOrientation };