Files
sx/examples/11-vector-math.sx
2026-02-24 15:10:02 +02:00

29 lines
514 B
Plaintext

#import "modules/std.sx";
math :: #import "modules/math";
vec3 :: (x:f32, y:f32, z:f32) -> Vector(3,f32) {
.[x, y, z];
}
main :: () {
a := vec3(1, 0, 0);
b := vec3(0, 1, 0);
// dot product
d := math.dot(a, b);
print("dot: {}\n", d);
// cross product
cr := math.cross(a, b);
print("cross: {}\n", cr);
// length
v := vec3(3, 4, 0);
len := math.length(v);
print("length: {}\n", len);
// normalize
n := math.normalize(v);
print("norm: {}\n", n);
}