Skip to content

Commit

Permalink
Merge pull request #16 from viamrobotics/autoconvert
Browse files Browse the repository at this point in the history
Autoconvert radians to degrees and vice versa when units are set
  • Loading branch information
micheal-parks authored Feb 29, 2024
2 parents db5b44e + cad138f commit 4facad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/three",
"version": "0.0.5",
"version": "0.0.6",
"license": "Apache-2.0",
"type": "module",
"files": [
Expand Down
6 changes: 6 additions & 0 deletions src/orientation-vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ export class OrientationVector {
}

setUnits(units: 'degrees' | 'radians'): this {
if (units === 'degrees' && this.#units === 'radians') {
this.#th = MathUtils.degToRad(this.#th);
} else if (units === 'radians' && this.#units === 'degrees') {
this.#th = MathUtils.radToDeg(this.#th);
}

this.#units = units;

return this;
Expand Down

0 comments on commit 4facad7

Please sign in to comment.