so... jai :D
This commit is contained in:
28
examples/11-vector-math.sx
Normal file
28
examples/11-vector-math.sx
Normal file
@@ -0,0 +1,28 @@
|
||||
#import "modules/std.sx";
|
||||
math :: #import "modules/std/math.sx";
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user