wmc/skycraft/linalg.js
Paul Mathieu 216ef470c5 skycraft: orbit computatino still borken
But we got ourselves a spaceship!
Improved the camera a bit. Now we can see the ship's orbit.
2022-11-08 00:33:51 -08:00

38 lines
660 B
JavaScript

export function cross(a, b) {
return [
a[1] * b[2] - a[2] * b[1],
a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0],
];
}
export function diff(a, b) {
return [
a[0] - b[0],
a[1] - b[1],
a[2] - b[2],
];
}
export function add(a, b) {
return [
a[0] + b[0],
a[1] + b[1],
a[2] + b[2],
];
}
export function norm(a) {
return Math.sqrt(a[0] ** 2 + a[1] ** 2 + a[2] ** 2);
}
export function dot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
export function scale(a, s) {
return [
a[0] * s,
a[1] * s,
a[2] * s,
];
}