Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
 Summary Activity SCM

# SCM Repository

[sml3d] View of /trunk/sml3d/src/geometry/plane-sig.sml
 [sml3d] / trunk / sml3d / src / geometry / plane-sig.sml # View of /trunk/sml3d/src/geometry/plane-sig.sml

Sun Feb 14 16:28:41 2010 UTC (9 years, 9 months ago) by jhr
Original Path: trunk/sml3d/src/geometry/plane3-sig.sml
File size: 1470 byte(s)
```  Added planes
```
```(* plane3-sig.sml
*
* COPYRIGHT (c) 2009 John Reppy (http://cs.uchicago.edu/~jhr)
*
* Generic interface to support for 3D planes.
*)

signature PLANE3 =
sig

type flt
type vec3 = {x : flt, y : flt, z : flt}
type vec4 = {x : flt, y : flt, z : flt, w : flt}

(* a plane is represented as its normal vector <nx, ny, nz> and the distance
* to the origin along that vector.
*)
type plane = {nx : flt, ny : flt, nz : flt, d : flt}

(* axis aligned planes; the order of the axes determines the plane's
* facing following the right-hand rule.
*)
val xyPlane : plane	(* points toward +Z *)
val xzPlane : plane	(* points toward -Y *)
val yxPlane : plane (* points toward -Z *)
val yzPlane : plane (* points toward +X *)
val zxPlane : plane (* points toward +Y *)
val zyPlane : plane (* points toward -X *)

(* a plane defined by a point and normal vector (the normal does
* not have to be a unit vector).
*)
val fromPtNorm : {p : vec3, n : vec3} -> plane

(* a plane defined by a unit normal vector and the signed distance from
* the origin.
*)
val fromNormDist : {n : vec3, d : flt} -> plane

(* return the plane's unit normal vector *)
val norm : plane -> vec3

(* return signed distance from plane to point (positive means the
* point is in front of the plane and negative means that it is
* behind.
*)
val distance : plane * vec3 -> flt

end
```