so... jai :D
This commit is contained in:
17
examples/modules/math.sx
Normal file
17
examples/modules/math.sx
Normal file
@@ -0,0 +1,17 @@
|
||||
#import "std.sx";
|
||||
|
||||
dot :: (a: Vector(3,f32), b: Vector(3,f32)) -> f32 {
|
||||
return a.x*b.x + a.y*b.y + a.z*b.z;
|
||||
}
|
||||
|
||||
cross :: (a: Vector(3,f32), b: Vector(3,f32)) -> Vector(3,f32) {
|
||||
.[a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x];
|
||||
}
|
||||
|
||||
length :: (v: Vector(3,f32)) -> f32 {
|
||||
return sqrt(dot(v, v));
|
||||
}
|
||||
|
||||
normalize :: (v: Vector(3,f32)) -> Vector(3,f32) {
|
||||
return v / length(v);
|
||||
}
|
||||
Reference in New Issue
Block a user