Skip to content

Commit

Permalink
fix: orientation relative
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Dec 2, 2023
1 parent 0fd432f commit 62fbef0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/data/position/RelativeOrientation.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import { Orientation } from './Orientation';
import { Accuracy, Accuracy1D } from '../values';
import { AngleUnit, Quaternion } from '../../utils';
import { SerializableObject } from '../decorators';
import { RelativePosition } from './RelativePosition';
import { Accuracy } from '../values';

/**
* Relative orientation relative to another object. This indicates the rotation
* relative to another reference object.
*/
@SerializableObject()
export class RelativeOrientation extends RelativePosition<Orientation, AngleUnit> {
constructor(
referenceObject?: any,
x?: number,
y?: number,
z?: number,
w?: number,
accuracy?: Accuracy<AngleUnit, number>,
) {
super(referenceObject, new Orientation(), AngleUnit.DEGREE);
this.referenceValue.x = x;
this.referenceValue.y = y;
this.referenceValue.z = z;
this.referenceValue.w = w;
this.accuracy = accuracy || new Accuracy1D(0, AngleUnit.RADIAN);
constructor(referenceObject?: any, orientation?: Orientation) {
super(referenceObject, orientation, AngleUnit.DEGREE);
}

/**
* Orientation accuracy
* @returns {Accuracy} Position accuracy
*/
get accuracy(): Accuracy<AngleUnit, any> {
return this.referenceValue.accuracy;
}

set accuracy(value: Accuracy<AngleUnit, any>) {
if (!value) {
throw new Error(`Accuracy can not be undefined!`);
}
this.referenceValue.accuracy = value;
}

static fromQuaternion(quat: Quaternion | THREE.Quaternion): Orientation {
Expand Down
2 changes: 1 addition & 1 deletion src/data/position/RelativePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class RelativePosition<T = number, U extends Unit = Unit> implements Posi
if (!value) {
throw new Error(`Accuracy can not be undefined!`);
}
this.accuracy = value;
this._accuracy = value;
}

constructor(referenceObject?: any, value?: T, unit?: U) {
Expand Down

0 comments on commit 62fbef0

Please sign in to comment.