1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-30 11:40:27 +02:00

this rename is absolutely stupid

This commit is contained in:
Pomax
2020-08-20 13:01:32 -07:00
parent 59fdafb2c5
commit d92e370bd1
470 changed files with 22 additions and 9 deletions

View File

@@ -0,0 +1,35 @@
/**
* A cabinet projection utility
*/
// 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;
return {
x: offset.x + x + (z / 2) * Math.cos(phi),
y: offset.y + y + (z / 2) * Math.sin(phi),
};
}
// and some rebuilt planar projectors
function projectXY(p, offset, phi) {
return project({ x: p.x, y: p.y, z: 0 }, offset, phi);
}
function projectXZ(p, offset, phi) {
return project({ x: p.x, y: 0, z: p.z }, offset, phi);
}
function projectYZ(p, offset, phi) {
return project({ x: 0, y: p.y, z: p.z }, offset, phi);
}
export { project, projectXY, projectXZ, projectYZ }