mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-28 10:40:52 +02:00
full regeneration
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
/**
|
||||
* A cabinet projection utility
|
||||
* A cabinet projection utility library
|
||||
*/
|
||||
|
||||
// Universal projector function
|
||||
// Universal projector function:
|
||||
|
||||
function project(point3d, offset = { x: 0, y: 0 }, phi = -Math.PI / 6) {
|
||||
// what they rarely tell you: if you want Z to "go up",
|
||||
// X to "come out of the screen", and Y to be the "left/right",
|
||||
// we need to switch some coordinates around:
|
||||
const x = point3d.y,
|
||||
y = -point3d.z,
|
||||
z = -point3d.x;
|
||||
const a = point3d.y,
|
||||
b = -point3d.z,
|
||||
c = -point3d.x / 2;
|
||||
|
||||
return {
|
||||
x: offset.x + x + (z / 2) * Math.cos(phi),
|
||||
y: offset.y + y + (z / 2) * Math.sin(phi),
|
||||
x: offset.x + a + c * Math.cos(phi),
|
||||
y: offset.y + b + c * Math.sin(phi),
|
||||
};
|
||||
}
|
||||
|
||||
// and some rebuilt planar projectors
|
||||
// and some planar projectors:
|
||||
|
||||
function projectXY(p, offset, phi) {
|
||||
return project({ x: p.x, y: p.y, z: 0 }, offset, phi);
|
||||
}
|
||||
@@ -30,6 +32,4 @@ function projectYZ(p, offset, phi) {
|
||||
return project({ x: 0, y: p.y, z: p.z }, offset, phi);
|
||||
}
|
||||
|
||||
|
||||
export { project, projectXY, projectXZ, projectYZ }
|
||||
|
||||
export { project, projectXY, projectXZ, projectYZ };
|
||||
|
Reference in New Issue
Block a user