소스 검색

Added some new stuff to geom types.

Mark Sibly 9 년 전
부모
커밋
64cd36e099
3개의 변경된 파일47개의 추가작업 그리고 9개의 파일을 삭제
  1. 28 8
      modules/std/geom/affinemat3.monkey2
  2. 12 0
      modules/std/geom/mat4.monkey2
  3. 7 1
      modules/std/geom/vec2.monkey2

+ 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.
 	#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 )
 		Return Transform( 1,0,0,1,tx,ty )
 	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.
 	#end
 	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.
 	#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 )
 		Return Transform( sx,0,0,sy,0,0 )
 	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
 	#end
 	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
 	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 )
 
 		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()
 		Return Sqrt( x*x+y*y )
 	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.
 	#end
 	Method Dot:Double( v:Vec2 )