aboutsummaryrefslogtreecommitdiff
path: root/examples/vectors
diff options
context:
space:
mode:
Diffstat (limited to 'examples/vectors')
-rw-r--r--examples/vectors/vectors.tm11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/vectors/vectors.tm b/examples/vectors/vectors.tm
index b2533be4..c07880a5 100644
--- a/examples/vectors/vectors.tm
+++ b/examples/vectors/vectors.tm
@@ -83,11 +83,13 @@ struct IVec2(x,y:Int):
func divided_by(v:IVec2, divisor:Int->IVec2; inline):
return IVec2(v.x/divisor, v.y/divisor)
func length(v:IVec2->Num; inline):
- return Num.sqrt(v.x*v.x + v.y*v.y)
+ x := Num(v.x)
+ y := Num(v.y)
+ return Num.sqrt(x*x + y*y)
func dist(a,b:IVec2->Num; inline):
return a:minus(b):length()
func angle(v:IVec2->Num; inline):
- return Num.atan2(v.y, v.x)
+ return Num.atan2(Num(v.y), Num(v.x))
struct IVec3(x,y,z:Int):
ZERO := IVec3(0, 0, 0)
@@ -106,7 +108,10 @@ struct IVec3(x,y,z:Int):
func divided_by(v:IVec3, divisor:Int->IVec3; inline):
return IVec3(v.x/divisor, v.y/divisor, v.z/divisor)
func length(v:IVec3->Num; inline):
- return Num.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)
+ x := Num(v.x)
+ y := Num(v.y)
+ z := Num(v.z)
+ return Num.sqrt(x*x + y*y + z*z)
func dist(a,b:IVec3->Num; inline):
return a:minus(b):length()