Paul Mathieu
216ef470c5
But we got ourselves a spaceship! Improved the camera a bit. Now we can see the ship's orbit.
38 lines
660 B
JavaScript
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,
|
|
];
|
|
} |