Explorar o código

Added some new stuff to geom types.

Mark Sibly %!s(int64=9) %!d(string=hai) anos
pai
achega
64cd36e099

+ 28 - 8
modules/std/geom/affinemat3.monkey2

@@ -100,14 +100,14 @@ Struct AffineMat3<T>
 	
 	
 	#rem monkeydoc Applies a translation transformation to the matrix and returns the result.
 	#rem monkeydoc Applies a translation transformation to the matrix and returns the result.
 	#end
 	#end
-	Method Translate:AffineMat3( v:Vec2<T> )
-		Return Transform( 1,0,0,1,v.x,v.y )
-	End
-	
 	Method Translate:AffineMat3( tx:T,ty:T )
 	Method Translate:AffineMat3( tx:T,ty:T )
 		Return Transform( 1,0,0,1,tx,ty )
 		Return Transform( 1,0,0,1,tx,ty )
 	End
 	End
 	
 	
+	Method Translate:AffineMat3( tv:Vec2<T> )
+		Return Transform( 1,0,0,1,tv.x,tv.y )
+	End
+	
 	#rem monkeydoc Applies a rotation transformation to the matrix and returns the result.
 	#rem monkeydoc Applies a rotation transformation to the matrix and returns the result.
 	#end
 	#end
 	Method Rotate:AffineMat3( rz:Double )
 	Method Rotate:AffineMat3( rz:Double )
@@ -116,14 +116,34 @@ Struct AffineMat3<T>
 	
 	
 	#rem monkeydoc Applies a scale transformation to the matrix and returns the result.
 	#rem monkeydoc Applies a scale transformation to the matrix and returns the result.
 	#end
 	#end
-	Method Scale:AffineMat3( v:Vec2<T> )
-		Return Transform( v.x,0,0,v.y,0,0 )
-	End
-	
 	Method Scale:AffineMat3( sx:T,sy:T )
 	Method Scale:AffineMat3( sx:T,sy:T )
 		Return Transform( sx,0,0,sy,0,0 )
 		Return Transform( sx,0,0,sy,0,0 )
 	End
 	End
 
 
+	Method Scale:AffineMat3( sv:Vec2<T> )
+		Return Transform( sv.x,0,0,sv.y,0,0 )
+	End
+	
+	Function Translation:AffineMat3( tx:T,ty:T )
+		Return New AffineMat3( 1,0,0,1,tx,ty )
+	End
+	
+	Function Translation:AffineMat3( tv:Vec2<T> )
+		Return New AffineMat3( 1,0,0,1,tv.x,tv.y )
+	End
+	
+	Function Rotation:AffineMat3( rz:Double )
+		Return New AffineMat3( Cos( rz ),-Sin( rz ),Sin( rz ),Cos( rz ),0,0 )
+	End
+	
+	Function Scaling:AffineMat3( sx:T,sy:T )
+		Return New AffineMat3( sx,0,0,sy,0,0 )
+	End
+
+	Function Scaling:AffineMat3( sv:Vec2<T> )
+		Return New AffineMat3( sv.x,0,0,sv.y,0,0 )
+	End
+
 	#rem monkeydoc @hidden
 	#rem monkeydoc @hidden
 	#end
 	#end
 	Function Ortho:AffineMat3( left:T,right:T,bottom:T,top:T )
 	Function Ortho:AffineMat3( left:T,right:T,bottom:T,top:T )

+ 12 - 0
modules/std/geom/mat4.monkey2

@@ -59,6 +59,18 @@ Struct Mat4<T>
 		Return r
 		Return r
 	End
 	End
 	
 	
+	Function Translation:Mat4( tx:T,ty:T,tz:T )
+		Local r:=New Mat4
+		r.t.x=tx;r.t.y=ty;r.t.z=tz
+		Return r
+	End
+	
+	Function Scale:Mat4( sx:Float,sy:Float,sz:Float )
+		Local r:Mat4
+		r.i.x=sx;r.j.y=sy;r.k.z=sz;r.t.w=1
+		Return r
+	End
+	
 	Function Ortho:Mat4( left:Float,right:Float,bottom:Float,top:Float,near:Float,far:Float )
 	Function Ortho:Mat4( left:Float,right:Float,bottom:Float,top:Float,near:Float,far:Float )
 
 
 		Local w:=right-left,h:=top-bottom,d:=far-near
 		Local w:=right-left,h:=top-bottom,d:=far-near

+ 7 - 1
modules/std/geom/vec2.monkey2

@@ -121,7 +121,13 @@ Struct Vec2<T>
 	Property Length:Double()
 	Property Length:Double()
 		Return Sqrt( x*x+y*y )
 		Return Sqrt( x*x+y*y )
 	End
 	End
-	
+
+	#rem monkeydoc The normal to the vector.
+	#end	
+	Property Normal:Vec2()
+		Return New Vec2( -y,x )
+	End
+
 	#rem monkeydoc Computes the dot product of the vector with another vector.
 	#rem monkeydoc Computes the dot product of the vector with another vector.
 	#end
 	#end
 	Method Dot:Double( v:Vec2 )
 	Method Dot:Double( v:Vec2 )