checkpoint gear generation work

This commit is contained in:
Stewart Allen 2024-07-18 20:13:50 -06:00
commit 156fe593ac
6 changed files with 99 additions and 27 deletions

View file

@ -109,6 +109,25 @@ function sqr(v) {
return v * v
}
// radians rotatition around origin
function rotate(x,y,radians) {
return [
x * Math.cos(radians) - y * Math.sin(radians),
y * Math.cos(radians) + x * Math.sin(radians)
];
}
const deg2rad = (Math.PI / 180);
const rad2deg = (180 / Math.PI);
function toRadians(degrees) {
return degrees * deg2rad;
}
function toDegrees(radians) {
return radians * rad2deg;
}
/**
* return distance between two points
*/
@ -576,6 +595,7 @@ base.util = {
pwait,
ptimer,
flatten,
rotate,
dist2D,
distSq,
distSqv2,
@ -587,6 +607,8 @@ base.util = {
offsetPrecision,
circleCenter,
numOrDefault,
toRadians,
toDegrees,
thetaDiff,
intersect,
inRange,

View file

@ -551,6 +551,13 @@ class Point {
this.z += delta.z;
return this;
}
// radians rotatition in XY around origin
rotate(angle) {
const { x, y } = this;
this.x = x * Math.cos(angle) - y * Math.sin(angle);
this.y = y * Math.cos(angle) + x * Math.sin(angle);
}
}
function dot(u, v) {

View file

@ -1094,6 +1094,7 @@ class Polygon {
} else if (this.isClockwise() !== poly.isClockwise()) {
this.reverse();
}
return this;
}
/**
@ -1105,6 +1106,7 @@ class Polygon {
} else if (this.isClockwise() === poly.isClockwise()) {
this.reverse();
}
return this;
}
/**