Mark Sibly 7 vuotta sitten
vanhempi
commit
d5a6dd05d8
2 muutettua tiedostoa jossa 9 lisäystä ja 19 poistoa
  1. 0 4
      modules/std/geom/box.monkey2
  2. 9 15
      modules/std/geom/plane.monkey2

+ 0 - 4
modules/std/geom/box.monkey2

@@ -1,12 +1,8 @@
 
 Namespace std.geom
 
-#rem monkeydoc @hidden
-#end
 Alias Boxf:Box<Float>
 
-#rem monkeydoc @hidden
-#end
 Struct Box<T>
 
 	Const FullBounds:=New Box( -1000000,-1000000,-1000000,1000000,1000000,1000000 )

+ 9 - 15
modules/std/geom/plane.monkey2

@@ -1,12 +1,8 @@
 
 Namespace std.geom
 
-#rem monkeydoc @hidden
-#end
 Alias Planef:Plane<Float>
 
-#rem monkeydoc @hidden
-#end
 Struct Plane<T>
 
 	Field n:Vec3<T>
@@ -15,55 +11,53 @@ Struct Plane<T>
 	Method New()
 	End
 	
+	Method New( nx:Float,ny:Float,nz:Float,d:Float )
+		n.x=nx;n.y=ny;n.z=nz;Self.d=d
+	End
+	
 	Method New( n:Vec3<T>,d:T )
-		
 		Self.n=n
 		Self.d=d
 	End
 	
 	Method New( p:Vec3<T>,n:Vec3<T> )
-		
 		Self.n=n
 		Self.d=-n.Dot( p )
 	End
 	
 	Method New( v0:Vec3<T>,v1:Vec3<T>,v2:Vec3<T> )
-		
 		n=(v1-v0).Cross(v2-v0).Normalize()
 		d=-n.Dot( v0 )
 	End
 	
 	Operator-:Plane()
-	
 		Return New Plane( -n,-d )
 	End
 	
 	Method Distance:Double( p:Vec3<T> )
-		
 		Return n.Dot( p )+d
 	End
 	
 	Method Nearest:Vec3<T>( p:Vec3<T> )
-		
 		Return p-n*Distance( p )
 	End
 	
+	Method Normalize:Plane()
+		Local l:=n.Length
+		Return New Planef( n/l,d/l )
+	End
+	
 	Method TIntersect:Double( line:Line<T> )
-		
 		Return -Distance( line.o )/n.Dot( line.d )
 	End
 	
 	Method Intersect:Vec3<T>( line:Line<T> )
-		
 		Return line * TIntersect( line )
 	End
 	
 	Method Intersect:Line<T>( p:Plane<T> )
-		
 		Local v:=n.Cross( p.n ).Normalize()
-
 		Local o:=p.Intersect( New Line<T>( n*-d,n.Cross( v ) ) )
-		
 		Return New Line<T>( o,v )
 	End