-
-
Save GabiGrin/0698d5c97a7415a85c3dcc9a07fb5e7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Vector } from "vanilla-vectors-3d"; | |
const opts = `XXXX | |
X | |
Y | |
Z | |
XX | |
XY | |
XZ | |
YX | |
YY | |
ZY | |
ZZ | |
XXX | |
XXY | |
XXZ | |
XYX | |
XYY | |
XZZ | |
YXX | |
YYY | |
ZZZ | |
XXXY | |
XXYX | |
XYXX | |
XYYY`.split("\n"); | |
export const rotate = (v, opt) => { | |
let vec = new Vector(v.x, v.y, v.z); | |
return opt.split("").reduce((prev, d) => { | |
if (d === "X") { | |
return prev.rotate("x", 90); | |
} | |
if (d === "Y") { | |
return prev.rotate("y", 90); | |
} | |
if (d === "Z") { | |
return prev.rotate("z", 90); | |
} | |
}, vec); | |
}; | |
const v = new Vector(1, 2, 3); | |
const all = opts.map((o) => rotate(v, o)).map((s) => `${s.x},${s.y},${s.z}`); | |
const s = new Set(all); | |
document.write(`Size is: ${s.size}`); | |
console.log(s.size); | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment