[MLton-commit] r6663

Vesa Karvonen vesak at mlton.org
Tue Jul 1 11:54:02 PDT 2008


The beginnings of a library for basic math primitives for 3D graphics.

----------------------------------------------------------------------

A   mltonlib/trunk/org/mlton/vesak/math3d/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/LICENSE
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/README
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-plane.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-quat.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rbt.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rot.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-seq.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-vec.fun
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/common.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/mlton.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/polyml.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib-no-infixes.mlb
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.mlb
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.use
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/common.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/infixes.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/mlton.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/polyml.sml
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/plane.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/quat.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rbt.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rot.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/scalar.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/seq.sig
A   mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/vec.sig

----------------------------------------------------------------------

Copied: mltonlib/trunk/org/mlton/vesak/math3d/unstable/LICENSE (from rev 6658, mltonlib/trunk/org/mlton/vesak/parsec/unstable/LICENSE)

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/README
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/README	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/README	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,57 @@
+Basic 3D Math Primitives
+------------------------
+
+   This library contains some basic math primitives for 3D graphics.  No
+   attempt is necessarily made to generalize the design beyond the
+   requirements of basic 3D graphics.
+
+
+Info
+----
+
+   License:         MLton license (a BSD-style license)
+   Portability:     portable
+   Ported to:       MLton, Poly/ML
+   Stability:       experimental
+   Maintainer:      Vesa Karvonen <vesa.a.j.k at gmail.com>
+
+
+About Library Organization
+--------------------------
+
+   public/
+
+      This directory contains the documented signature definitions (*.sig)
+      and listings of all top-level bindings exported by this library
+      (export/*.sml).  The contents of this directory should ideally provide
+      sufficient documentation to use the library.
+
+   lib.{mlb, use}
+
+      These build files define the library.
+
+   detail/
+
+      This directory contains the implementation details of the library.
+
+
+Contributions
+-------------
+
+   The signatures and structures defined by this library are not meant to
+   be cast in stone!  We welcome contributions including new
+   functionality, bug fixes, and ports to new compilers.  The recommended
+   submit method for small contributions to this library is to send a
+   message with a brief description of the proposed contribution as well
+   as a patch containing full code and documentation (signature comments)
+   to either the MLton-user list
+
+      mlton-user at mlton.org
+
+   or the MLton list
+
+      mlton at mlton.org .
+
+   For larger extensions or changes we recommend that you first contact
+   the active maintainer(s) of this library.  The preferred contact method
+   is through the above mailing lists.

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-plane.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-plane.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-plane.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,50 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkPlane (Arg : PLANE_CORE) : PLANE = struct
+   open Arg open RBT open Vec open Scalar open Math
+
+   datatype t = PLANE of {n : Vec.t, d : Scalar.t}
+   val t = let
+      open Generic
+   in
+      data' (C1'"PLANE" (record (R'"n" Vec.t *` R'"d" Scalar.t)))
+            (fn (PLANE {n=n, d=d}) => (n & d),
+             fn (n & d) => (PLANE {n=n, d=d}))
+   end
+
+   fun out (PLANE r) = r
+   val normal = #n o out
+   val distance = #d o out
+
+   val eps = nextAfter (fromInt 1, fromInt 2) - fromInt 1
+   val sqrtEps = sqrt eps
+
+   fun renormalize' nn (PLANE {n, d}) =
+       if abs (nn - fromInt 1) < sqrtEps
+       then PLANE {n = n, d = d}
+       else case sqrt nn of m => PLANE {n = n |* fromInt 1 / m, d = d * m}
+
+   fun renormalize (plane as PLANE {n, ...}) =
+       renormalize' (norm n) plane
+
+   fun plane {normal, distance} =
+       case norm normal
+        of n => if n < eps
+                then fail "Plane.plane"
+                else renormalize' n (PLANE {n=normal, d=distance})
+
+   fun translate translation (PLANE {n, d}) =
+       PLANE {n = n, d = d + dot (translation, n)}
+
+   fun rotate rot =
+       case Rot.transform rot
+        of rotate =>
+           fn PLANE {n, d} => renormalize (PLANE {n = rotate n, d = d})
+
+   fun transform rbt =
+       translate (RBT.translation rbt) o rotate (RBT.rotation rbt)
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-plane.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-quat.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-quat.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-quat.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,100 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkQuat (Arg : QUAT_CORE) : QUAT = struct
+   open Arg open Vec open Scalar open Math
+
+   datatype t = QUAT of {s : Scalar.t, v : Vec.t}
+   fun out (QUAT r) = r
+
+   val t = let
+      open Generic
+   in
+      data' (C1'"QUAT" (record (R'"s" Scalar.t *` R'"v" Vec.t)))
+            (fn QUAT {s=s, v=v} => s & v,
+             fn s & v => QUAT {s=s, v=v})
+   end
+
+   val scalar = #s o out
+   val vec = #v o out
+
+   fun quat {scalar, vec} = QUAT {s=scalar, v=vec}
+
+   fun fromScalar s = QUAT {s = s, v = Vec.zero}
+   fun fromVec v = QUAT {s = fromInt 0, v = v}
+
+   fun rot {axis, rad} =
+       QUAT {s = cos rad,
+             v = axis |* invMag axis * sin rad} (* XXX Vec.withMag *)
+
+   val {x=rotX, y=rotY, z=rotZ} =
+       toXYZ (Seq.map (fn axis => fn {rad} =>
+                          QUAT {s = cos rad, v = update axis (zero, sin rad)})
+                      Seq.selector)
+
+   val one = fromScalar (fromInt 1)
+   val zero = fromScalar (fromInt 0)
+
+   fun ~! (QUAT {s, v}) = QUAT {s = ~s, v = ~|v}
+
+   fun norm (QUAT {s, v}) = Scalar.sq s + Vec.norm v
+   val mag = sqrt o norm
+   val invMag = fromInt 1 <\ op / o mag (* XXX invSqrt *)
+
+   fun conj (QUAT {s, v}) = QUAT {s = s, v = ~|v}
+   fun inv (q as QUAT {s, v}) =
+       case fromInt 1 / norm q
+        of k => QUAT {s = k * s, v = ~k *| v}
+
+   local
+      fun mk op + op |+| =
+          case fn (l, r) => QUAT {s = scalar l + r, v = vec l}
+           of qxs =>
+              (fn (l, r) =>
+                  QUAT {s = scalar l + scalar r, v = vec l |+| vec r},
+               qxs, qxs o swap)
+   in
+      val (op !+!, op !+, op +!) = mk op + op |+|
+      val (op !-!, op !-, op -!) = mk op - op |-|
+   end
+
+   fun l !*! r =
+       QUAT {s = scalar l * scalar r - dot (vec l, vec r),
+             v = cross (vec l, vec r)
+                  |+| scalar r *| vec l
+                  |+| scalar l *| vec r}
+   fun (QUAT {s, v}) !* k = QUAT {s = s * k, v = v |* k}
+   val op *! = op !* o swap
+
+   fun l !/! r = l !*! inv r
+   fun l !/ r = l !* fromInt 1 / r
+   fun l /! r = l *! inv r
+
+   val eps = nextAfter (fromInt 1, fromInt 2) - fromInt 1
+
+   fun normalize q = let
+      val n = norm q
+   in
+      if n < eps then zero else q !* fromInt 1 / sqrt n (* XXX invSqrt *)
+   end
+
+   fun lerp (l, r) t = l !* (fromInt 1 - t) !+! r !* t
+   fun nlerp (l, r) = normalize o lerp (l, r)
+
+   fun toRotMatrix (q as QUAT {s, v}) = let
+      val {x, y, z} = Vec.toXYZ (Vec.toSeq v)
+      val k = fromInt 2 / norm q
+      val kx = k*x val ky = k*y val kz = k*z
+      val xkx = x*kx val yky = y*ky val zkz = z*kz
+      val i = fromInt 1
+      val xky = x*ky val ykz = y*kz val zkx = z*kx
+      val skx = s*kx val sky = s*ky val skz = s*kz
+   in
+      {m11 = i-(yky+zkz), m12 =   (xky-skz), m13 =   (zkx+sky),
+       m21 =   (xky+skz), m22 = i-(zkz+xkx), m23 =   (ykz-skx),
+       m31 =   (zkx-sky), m32 =   (ykz+skx), m33 = i-(xkx+yky)}
+   end
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-quat.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rbt.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rbt.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rbt.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,56 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkRBT (Arg : RBT_CORE) : RBT = struct
+   open Arg open Rot open Vec open Scalar
+
+   datatype t = RBT of {r : Rot.t, t : Vec.t}
+   fun out (RBT r) = r
+
+   val t = let
+      open Generic
+   in
+      data' (C1'"RBT" (record (R'"r" Rot.t *` R'"t" Vec.t)))
+            (fn (RBT {r=r, t=t}) => (r & t),
+             fn (r & t) => (RBT {r=r, t=t}))
+   end
+
+   val identity = RBT {r = Rot.identity, t = zero}
+
+   fun rbt {rotation, translation} = RBT {r=rotation, t=translation}
+
+   val rotation = #r o out
+   val translation = #t o out
+
+   fun fromRotation r = RBT {r = r, t = zero}
+   fun fromTranslation t = RBT {r = Rot.identity, t = t}
+
+   fun toMatrix (RBT {r, t}) = let
+      val {m11, m12, m13,
+           m21, m22, m23,
+           m31, m32, m33} = toRotMatrix r
+      val s0 = fromInt 0 val s1 = fromInt 1
+      val {x, y, z} = toXYZ (toSeq t)
+   in
+      {m11=m11, m12=m12, m13=m13, m14=x,
+       m21=m21, m22=m22, m23=m23, m24=y,
+       m31=m31, m32=m32, m33=m33, m34=z,
+       m41=s0,  m42=s0,  m43=s0,  m44=s1}
+   end
+
+   fun transform (RBT {r, t}) =
+       case Rot.transform r of r => fn p => r p |+| t
+
+   val rotate = Rot.transform o rotation
+   fun translate rbt = translation rbt <\ op |+|
+
+   fun (RBT l) %*% (RBT r) =
+       RBT {r = #r l @*@ #r r,
+            t = #t l |+| Rot.transform (#r l) (#t r)}
+
+   fun inv (RBT {r, t}) =
+       case Rot.inv r of r => RBT {r = r, t = Rot.transform r (~|t)}
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rbt.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rot.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rot.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rot.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,87 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkRot (Arg : ROT_CORE) : ROT = struct
+   open Arg open Quat open Scalar open Math
+
+   datatype t = ROT of Quat.t
+   fun out (ROT q) = q
+   val t = let open Generic in data' (C1'"ROT" Quat.t) (out, ROT) end
+
+   val identity = ROT one
+
+   val axis = vec o out
+   val rad = undefined
+
+   val eps = nextAfter (fromInt 1, fromInt 2) - fromInt 1
+   val sqrtEps = sqrt eps
+
+   val fromQuat = ROT o Quat.normalize
+   val toQuat = out
+
+   val rot = ROT o rot
+
+   val rotX = ROT o rotX
+   val rotY = ROT o rotY
+   val rotZ = ROT o rotZ
+
+   fun toRotMatrix (ROT q) = let
+      val s = Quat.scalar q
+      val v = Quat.vec q
+      val {x, y, z} = Vec.toXYZ (Vec.toSeq v)
+      val k = fromInt 2
+      val kx = k*x val ky = k*y val kz = k*z
+      val xkx = x*kx val yky = y*ky val zkz = z*kz
+      val i = fromInt 1
+      val xky = x*ky val ykz = y*kz val zkx = z*kx
+      val skx = s*kx val sky = s*ky val skz = s*kz
+   in
+      {m11 = i-(yky+zkz), m12 =   (xky-skz), m13 =   (zkx+sky),
+       m21 =   (xky+skz), m22 = i-(zkz+xkx), m23 =   (ykz-skx),
+       m31 =   (zkx-sky), m32 =   (ykz+skx), m33 = i-(xkx+yky)}
+   end
+
+   fun toMatrix r = let
+      val {m11, m12, m13,
+           m21, m22, m23,
+           m31, m32, m33} = toRotMatrix r
+      val s0 = fromInt 0
+      val s1 = fromInt 1
+   in
+      {m11 = m11, m12 = m12, m13 = m13, m14 = s0,
+       m21 = m21, m22 = m22, m23 = m23, m24 = s0,
+       m31 = m31, m32 = m32, m33 = m33, m34 = s0,
+       m41 = s0,  m42 = s0,  m43 = s0,  m44 = s1}
+   end
+
+   fun transform r =
+       case toRotMatrix r
+        of {m11, m12, m13,
+            m21, m22, m23,
+            m31, m32, m33} =>
+           fn p =>
+              case Vec.toXYZ (Vec.toSeq p)
+               of {x, y, z} =>
+                  Vec.fromSeq
+                   (Vec.fromXYZ
+                     {x = m11*x + m12*y + m13*z,
+                      y = m21*x + m22*y + m23*z,
+                      z = m31*x + m32*y + m33*z})
+
+   fun renormalize q = let
+      val n = norm q
+   in
+      if abs (n - fromInt 1) < sqrtEps
+      then q
+      else q !* fromInt 1 / sqrt n
+   end
+
+   fun (ROT l) @*@ (ROT r) = ROT (renormalize (l !*! r))
+
+   val inv = ROT o conj o out
+
+   fun lerp (ROT l, ROT r) = ROT o nlerp (l, r)
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-rot.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-seq.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-seq.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-seq.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,30 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkSeq (Arg : SEQ_CORE) : SEQ = struct
+   open Arg
+   fun find p = findSome (fn x => if p x then SOME x else NONE)
+   fun all p = isNone o find (neg p)
+   fun exists p = isSome o find p
+   fun zipWith f (l, r) = let
+      val l = map INL l
+      val r = map INR r
+   in
+      map (fn s => f (Sum.outL (s l), Sum.outR (s r))) selector
+   end
+   fun zip ? = zipWith id ?
+   fun app e = ignore o map e
+   fun for s e = app e s
+   fun dup v = map (const v) selector
+   fun new th = map (th o ignore) selector
+   fun toList v = foldr op :: [] v
+   type 'a r = 'a ref
+   fun sub f v = case map ref v of r => ! (f r)
+   fun update f (v, s) = case map ref v of r => (f r := s ; map ! r)
+   fun sumWith f =
+       Sum.outR o foldr (fn (v, INL ()) => INR v
+                          | (v, INR s) => INR (f (s, v))) (INL ())
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-seq.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-vec.fun
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-vec.fun	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-vec.fun	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,62 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+functor MkVec (Arg : VEC_CORE) : VEC = struct
+   open Arg open Scalar Seq open Math
+
+   type t = Scalar.t Seq.t
+   val t = Seq.t Scalar.t
+
+   val fromSeq = id
+   val toSeq = id
+
+   fun diag s v = map (fn f => update f (dup s, sub f v)) selector
+
+   val e = diag (fromInt 0) (dup (fromInt 1))
+
+   val ~| = map Scalar.~
+
+   val zero = dup (fromInt 0)
+
+   local
+      fun mk f =
+          case zipWith f
+           of vv => vv & vv o Pair.map (id, dup) & vv o Pair.map (dup, id)
+   in
+      val op |+| & op |+ & op +| = mk op +
+      val op |-| & op |- & op -| = mk op -
+      val op |*| & op |* & op *| = mk op *
+      val op |/| & op |/ & op /| = mk op /
+   end
+
+   local
+      fun mk rel = all rel o zipWith id
+   in
+      val |<|  = mk op <
+      val |<=| = mk op <=
+      val |>|  = mk op >
+      val |>=| = mk op >=
+   end
+
+   val minElems = zipWith min
+   val maxElems = zipWith max
+
+   val dot = sumWith op + o op |*|
+   val norm = dot o Sq.mk
+   val mag = sqrt o norm
+   val invMag = fromInt 1 <\ op / o mag (* XXX invSqrt *)
+
+   val eps = nextAfter (fromInt 1, fromInt 2) - fromInt 1
+
+   fun normalize v = let
+      val n = norm v
+   in
+      if n < eps then zero else v |* fromInt 1 / sqrt n (* XXX invSqrt *)
+   end
+
+   fun lerp (l, r) t = l |* (fromInt 1 - t) |+| r |* t
+   fun nlerp (l, r) = normalize o lerp (l, r)
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/mk-vec.fun
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/common.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/common.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/common.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,77 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+local
+   open Generic
+   val x = L"x" val y = L"y" val z = L"z" val w = L"w"
+in
+   structure SeqXY =
+      MkSeq (type 'a t = {x : 'a, y : 'a}
+             fun t t =
+                 record' (R x t *` R y t)
+                         (fn {x=x, y=y} => (x & y),
+                          fn (x & y) => {x=x, y=y})
+             val selector : ('a t -> 'a) t = {x = #x, y = #y}
+             fun map f {x, y} = {x = f x, y = f y}
+             fun foldr f s {x, y} = f (x, f (y, s))
+             fun findSome f {x, y} =
+                 case f x of SOME r => SOME r | NONE =>
+                 f y)
+
+   structure SeqXYZ =
+      MkSeq (type 'a t = {x : 'a, y : 'a, z : 'a}
+             fun t t =
+                 record' (R x t *` R y t *` R z t)
+                         (fn {x=x, y=y, z=z} => (x & y & z),
+                          fn (x & y & z) => {x=x, y=y, z=z})
+             val selector : ('a t -> 'a) t = {x = #x, y = #y, z = #z}
+             fun map f {x, y, z} = {x = f x, y = f y, z = f z}
+             fun foldr f s {x, y, z} = f (x, f (y, f (z, s)))
+             fun findSome f {x, y, z} =
+                 case f x of SOME r => SOME r | NONE =>
+                 case f y of SOME r => SOME r | NONE =>
+                 f z)
+
+   structure SeqXYZW =
+      MkSeq (type 'a t = {x : 'a, y : 'a, z : 'a, w : 'a}
+             fun t t =
+                 record' (R x t *` R y t *` R z t *` R w t)
+                         (fn {x=x, y=y, z=z, w=w} => (x & y & z & w),
+                          fn (x & y & z & w) => {x=x, y=y, z=z, w=w})
+             val selector : ('a t -> 'a) t = {x = #x, y = #y, z = #z, w = #w}
+             fun map f {x, y, z, w} = {x = f x, y = f y, z = f z, w = f w}
+             fun foldr f s {x, y, z, w} = f (x, f (y, f (z, f (w, s))))
+             fun findSome f {x, y, z, w} =
+                 case f x of SOME r => SOME r | NONE =>
+                 case f y of SOME r => SOME r | NONE =>
+                 case f z of SOME r => SOME r | NONE =>
+                 f w)
+end
+
+structure Vec2D = MkVec (structure Scalar = Real and Seq = SeqXY)
+structure Vec3D = MkVec (structure Scalar = Real and Seq = SeqXYZ)
+structure Vec4D = MkVec (structure Scalar = Real and Seq = SeqXYZW)
+
+structure Vec3D = struct
+   open Vec3D
+   structure Vec4 = Vec4D
+   val toXYZ = id
+   val fromXYZ = id
+   fun cross (a : t, b : t) = let
+      open Scalar
+      fun el u v = u a * v b - u b * v a
+   in
+      {x = el #y #z, y = el #z #x, z = el #x #y}
+   end
+   fun toVec4 w {x, y, z} : Vec4D.t = {x=x, y=y, z=z, w=w}
+   fun fromVec4 {x, y, z, w=_} : t = {x=x, y=y, z=z}
+end
+
+structure QuatD = MkQuat (structure Vec = Vec3D)
+structure RotD = MkRot (structure Quat = QuatD)
+structure RBTD = MkRBT (structure Rot = RotD)
+
+structure PlaneD = MkPlane (structure RBT = RBTD)


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/common.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/mlton.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/mlton.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/mlton.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,29 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+structure Vec2F = MkVec (structure Scalar = Real32 and Seq = SeqXY)
+structure Vec3F = MkVec (structure Scalar = Real32 and Seq = SeqXYZ)
+structure Vec4F = MkVec (structure Scalar = Real32 and Seq = SeqXYZW)
+
+structure Vec3F = struct
+   open Vec3F
+   structure Vec4 = Vec4F
+   val toXYZ = id
+   val fromXYZ = id
+   fun cross (a : t, b : t) = let
+      open Scalar
+      fun el u v = u a * v b - u b * v a
+   in
+      {x = el #y #z, y = el #z #x, z = el #x #y}
+   end
+   fun toVec4 w {x, y, z} : Vec4F.t = {x=x, y=y, z=z, w=w}
+   fun fromVec4 {x, y, z, w=_} : t = {x=x, y=y, z=z}
+end
+
+structure QuatF = MkQuat (structure Vec = Vec3F)
+structure RotF = MkRot (structure Quat = QuatF)
+structure RBTF = MkRBT (structure Rot = RotF)
+structure PlaneF = MkPlane (structure RBT = RBTF)


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/mlton.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/polyml.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/polyml.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/polyml.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,5 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/detail/ml/polyml.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib-no-infixes.mlb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib-no-infixes.mlb	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib-no-infixes.mlb	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,45 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+local
+   $(MLTON_LIB)/com/ssh/extended-basis/unstable/basis.mlb
+   $(APPLICATION)/generic.mlb
+   public/export/infixes.sml
+in
+   ann
+      "forceUsed"
+      "sequenceNonUnit warn"
+      "warnUnused true"
+   in
+      local
+         public/scalar.sig
+
+         public/seq.sig
+         detail/mk-seq.fun
+
+         public/vec.sig
+         detail/mk-vec.fun
+
+         public/quat.sig
+         detail/mk-quat.fun
+
+         public/rot.sig
+         detail/mk-rot.fun
+
+         public/rbt.sig
+         detail/mk-rbt.fun
+
+         public/plane.sig
+         detail/mk-plane.fun
+
+         detail/ml/common.sml
+         detail/ml/$(SML_COMPILER).sml
+      in
+         public/export/common.sml
+         public/export/$(SML_COMPILER).sml
+      end
+   end
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib-no-infixes.mlb
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.mlb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.mlb	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.mlb	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,8 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+lib-no-infixes.mlb
+public/export/infixes.sml


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.mlb
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.use
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.use	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.use	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,26 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+lib ["${MLTON_LIB}/com/ssh/extended-basis/unstable/basis.use",
+     "${APPLICATION}/generic.use",
+     "public/export/infixes.sml",
+     "public/scalar.sig",
+     "public/seq.sig",
+     "detail/mk-seq.fun",
+     "public/vec.sig",
+     "detail/mk-vec.fun",
+     "public/quat.sig",
+     "detail/mk-quat.fun",
+     "public/rot.sig",
+     "detail/mk-rot.fun",
+     "public/rbt.sig",
+     "detail/mk-rbt.fun",
+     "public/plane.sig",
+     "detail/mk-plane.fun",
+     "detail/ml/common.sml",
+     "detail/ml/${SML_COMPILER}.sml",
+     "public/export/common.sml",
+     "public/export/${SML_COMPILER}.sml"] ;


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/lib.use
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/common.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/common.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/common.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,51 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Exported Signatures == *)
+
+signature PLANE = PLANE
+signature QUAT = QUAT
+signature RBT = RBT
+signature ROT = ROT
+signature SEQ = SEQ
+signature VEC = VEC
+signature VEC3 = VEC3
+
+(** == Exported Functors == *)
+
+signature SEQ_CORE = SEQ_CORE
+functor MkSeq (Arg : SEQ_CORE) : SEQ = MkSeq (Arg)
+
+signature VEC_CORE = VEC_CORE
+functor MkVec (Arg : VEC_CORE) : VEC = MkVec (Arg)
+
+signature QUAT_CORE = QUAT_CORE
+functor MkQuat (Arg : QUAT_CORE) : QUAT = MkQuat (Arg)
+
+signature ROT_CORE = ROT_CORE
+functor MkRot (Arg : ROT_CORE) : ROT = MkRot (Arg)
+
+signature RBT_CORE = RBT_CORE
+functor MkRBT (Arg : RBT_CORE) : RBT = MkRBT (Arg)
+
+signature PLANE_CORE = PLANE_CORE
+functor MkPlane (Arg : PLANE_CORE) : PLANE = MkPlane (Arg)
+
+(** == Exported Structures == *)
+
+structure SeqXY : SEQ = SeqXY
+structure SeqXYZ : SEQ = SeqXYZ
+structure SeqXYZW : SEQ = SeqXYZW
+
+structure Vec2D : VEC = Vec2D
+structure Vec3D : VEC3 = Vec3D
+structure Vec4D : VEC = Vec4D
+
+structure QuatD : QUAT = QuatD
+structure RotD : ROT = RotD
+structure RBTD : RBT = RBTD
+
+structure PlaneD : PLANE = PlaneD


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/common.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/infixes.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/infixes.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/infixes.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,41 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Infix Operators ==
+ *
+ * The choice of symbols has been made based on their appearance:
+ *
+ *     Symbol | Type       | Mnemonic
+ *    --------+------------+----------------------------------------------
+ *            | Scalar     | Same as usual
+ *          # | Matrix     | Rows and columns of scalars
+ *          ! | Quaternion | Consists of two parts: a scalar and a vector
+ *          @ | Rot        |
+ *          % | RBT        |
+ *          | | Vector     | A single row or column of scalars
+ *
+ * So, for example,
+ *
+ *> m #*| v |* s *! q
+ *
+ * means to compute the product of a matrix {m}, a vector {v}, a scalar
+ * {s}, and a quaternion {q}.
+ *
+ * Note that scalar operators have higher precedence in the Extended
+ * Basis library.
+ *)
+
+infix 7 !*! !* *! !/! !/ /!
+        #*! !*#
+        #*# #* *# #/# #/ /#
+        #*| |*#
+        @*@
+        %*% %*@ @*% %*| |*%
+        |*| |* *| |/| |/ /|
+
+infix 6 !+! !+ +! !-! !- -!
+        #+# #+ +# #-# #- -#
+        |+| |+ +| |-| |- -|


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/infixes.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/mlton.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/mlton.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/mlton.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,17 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Exported Structures for MLton == *)
+
+structure Vec2F : VEC = Vec2F
+structure Vec3F : VEC3 = Vec3F
+structure Vec4F : VEC = Vec4F
+
+structure QuatF : QUAT = QuatF
+structure RotF : ROT = RotF
+structure RBTF : RBT = RBTF
+
+structure PlaneF : PLANE = PlaneF


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/mlton.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/polyml.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/polyml.sml	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/polyml.sml	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,7 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Exported Structures for Poly ML == *)


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/export/polyml.sml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/plane.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/plane.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/plane.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,30 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Plane == *)
+
+signature PLANE_CORE = sig
+   structure RBT : RBT
+end
+
+signature PLANE = sig
+   include PLANE_CORE
+   structure Rot : ROT sharing Rot = RBT.Rot
+   structure Scalar : SCALAR sharing Scalar = RBT.Scalar
+   structure Vec : VEC3 sharing Vec = RBT.Vec
+
+   type t
+   val t : t Generic.Rep.t
+
+   val plane : {normal : Vec.t, distance : Scalar.t} -> t
+
+   val normal : t -> Vec.t
+   val distance : t -> Scalar.t
+
+   val translate : Vec.t -> t UnOp.t
+   val rotate : Rot.t -> t UnOp.t
+   val transform : RBT.t -> t UnOp.t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/plane.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/quat.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/quat.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/quat.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,58 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+signature QUAT_CORE = sig
+   structure Vec : VEC3
+end
+
+signature QUAT = sig
+   include QUAT_CORE
+   structure Scalar : SCALAR sharing Scalar = Vec.Scalar
+
+   type t
+   val t : t Generic.Rep.t
+
+   val quat : {scalar : Scalar.t, vec : Vec.t} -> t
+
+   val fromScalar : Scalar.t -> t
+   val fromVec : Vec.t -> t
+
+   val toRotMatrix :
+       t -> {m11 : Scalar.t, m12 : Scalar.t, m13 : Scalar.t,
+             m21 : Scalar.t, m22 : Scalar.t, m23 : Scalar.t,
+             m31 : Scalar.t, m32 : Scalar.t, m33 : Scalar.t}
+
+   val rot : {axis : Vec.t, rad : Scalar.t} -> t
+
+   val rotX : {rad : Scalar.t} -> t
+   val rotY : {rad : Scalar.t} -> t
+   val rotZ : {rad : Scalar.t} -> t
+
+   val scalar : t -> Scalar.t
+   val vec : t -> Vec.t
+
+   val one : t
+   val zero : t
+
+   val ~! : t UnOp.t
+
+   val !+! : t BinOp.t  val !+ : t * Scalar.t -> t  val +! : Scalar.t * t -> t
+   val !-! : t BinOp.t  val !- : t * Scalar.t -> t  val -! : Scalar.t * t -> t
+   val !*! : t BinOp.t  val !* : t * Scalar.t -> t  val *! : Scalar.t * t -> t
+   val !/! : t BinOp.t  val !/ : t * Scalar.t -> t  val /! : Scalar.t * t -> t
+
+   val norm : t -> Scalar.t
+   val mag : t -> Scalar.t
+   val invMag : t -> Scalar.t
+
+   val conj : t UnOp.t
+   val inv : t UnOp.t
+
+   val lerp : t Sq.t -> Scalar.t -> t
+   val nlerp : t Sq.t -> Scalar.t -> t
+
+   val normalize : t UnOp.t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/quat.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rbt.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rbt.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rbt.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,45 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(** == Rigid-Body Transform == *)
+
+signature RBT_CORE = sig
+   structure Rot : ROT
+end
+
+signature RBT = sig
+   include RBT_CORE
+   structure Quat : QUAT sharing Quat = Rot.Quat
+   structure Scalar : SCALAR sharing Scalar = Rot.Scalar
+   structure Vec : VEC3 sharing Vec = Rot.Vec
+
+   type t
+   val t : t Generic.Rep.t
+
+   val identity : t
+
+   val rbt : {rotation : Rot.t, translation : Vec.t} -> t
+
+   val fromRotation : Rot.t -> t
+   val fromTranslation : Vec.t -> t
+
+   val toMatrix :
+       t -> {m11 : Scalar.t, m12 : Scalar.t, m13 : Scalar.t, m14 : Scalar.t,
+             m21 : Scalar.t, m22 : Scalar.t, m23 : Scalar.t, m24 : Scalar.t,
+             m31 : Scalar.t, m32 : Scalar.t, m33 : Scalar.t, m34 : Scalar.t,
+             m41 : Scalar.t, m42 : Scalar.t, m43 : Scalar.t, m44 : Scalar.t}
+
+   val transform : t -> Vec.t UnOp.t
+   val rotate : t -> Vec.t UnOp.t
+   val translate : t -> Vec.t UnOp.t
+
+   val rotation : t -> Rot.t
+   val translation : t -> Vec.t
+
+   val %*% : t BinOp.t
+
+   val inv : t UnOp.t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rbt.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rot.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rot.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rot.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,51 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+signature ROT_CORE = sig
+   structure Quat : QUAT
+end
+
+signature ROT = sig
+   include ROT_CORE
+   structure Scalar : SCALAR sharing Scalar = Quat.Scalar
+   structure Vec : VEC3 sharing Vec = Quat.Vec
+
+   type t
+   val t : t Generic.Rep.t
+
+   val identity : t
+
+   val axis : t -> Vec.t
+   val rad : t -> Scalar.t
+
+   val fromQuat : Quat.t -> t
+   val toQuat : t -> Quat.t
+
+   val rot : {axis : Vec.t, rad : Scalar.t} -> t
+
+   val rotX : {rad : Scalar.t} -> t
+   val rotY : {rad : Scalar.t} -> t
+   val rotZ : {rad : Scalar.t} -> t
+
+   val toRotMatrix :
+       t -> {m11 : Scalar.t, m12 : Scalar.t, m13 : Scalar.t,
+             m21 : Scalar.t, m22 : Scalar.t, m23 : Scalar.t,
+             m31 : Scalar.t, m32 : Scalar.t, m33 : Scalar.t}
+
+   val toMatrix :
+       t -> {m11 : Scalar.t, m12 : Scalar.t, m13 : Scalar.t, m14 : Scalar.t,
+             m21 : Scalar.t, m22 : Scalar.t, m23 : Scalar.t, m24 : Scalar.t,
+             m31 : Scalar.t, m32 : Scalar.t, m33 : Scalar.t, m34 : Scalar.t,
+             m41 : Scalar.t, m42 : Scalar.t, m43 : Scalar.t, m44 : Scalar.t}
+
+   val transform : t -> Vec.t UnOp.t
+
+   val @*@ : t BinOp.t
+
+   val inv : t UnOp.t
+
+   val lerp : t Sq.t -> Scalar.t -> t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/rot.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/scalar.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/scalar.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/scalar.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,10 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+signature SCALAR = sig
+   include REAL
+   val t : t Generic.Rep.t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/scalar.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/seq.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/seq.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/seq.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,32 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+signature SEQ_CORE = sig
+   type 'a t
+   val t : 'a Generic.Rep.t -> 'a t Generic.Rep.t
+   val findSome : ('a -> 'b Option.t) -> 'a t -> 'b Option.t
+   val foldr : ('a * 'b -> 'b) -> 'b -> 'a t -> 'b
+   val map : ('a -> 'b) -> 'a t -> 'b t
+   val selector : ('a t -> 'a) t
+end
+
+signature SEQ = sig
+   include SEQ_CORE
+   val all : 'a UnPr.t -> 'a t UnPr.t
+   val app : 'a Effect.t -> 'a t Effect.t
+   val dup : 'a -> 'a t
+   val new : 'a Thunk.t -> 'a t
+   val exists : 'a UnPr.t -> 'a t UnPr.t
+   val find : 'a UnPr.t -> 'a t -> 'a Option.t
+   val for : 'a t -> 'a Effect.t Effect.t
+   val sumWith : 'a BinOp.t -> 'a t -> 'a
+   val toList : 'a t -> 'a List.t
+   val zip : 'a t * 'b t -> ('a * 'b) t
+   val zipWith : ('a * 'b -> 'c) -> 'a t * 'b t -> 'c t
+   type 'a r
+   val sub : ('a r t -> 'a r) -> 'a t -> 'a
+   val update : ('a r t -> 'a r) -> 'a t * 'a -> 'a t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/seq.sig
___________________________________________________________________
Name: svn:eol-style
   + native

Added: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/vec.sig
===================================================================
--- mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/vec.sig	2008-07-01 13:54:12 UTC (rev 6662)
+++ mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/vec.sig	2008-07-01 18:53:59 UTC (rev 6663)
@@ -0,0 +1,64 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+signature VEC_CORE = sig
+   structure Scalar : SCALAR
+   structure Seq : SEQ
+end
+
+signature VEC = sig
+   include VEC_CORE
+
+   type t (* = Scalar.t Seq.t *)
+   val t : t Generic.Rep.t
+
+   val fromSeq : Scalar.t Seq.t -> t
+   val toSeq : t -> Scalar.t Seq.t
+
+   val sub : (Scalar.t Seq.r Seq.t -> Scalar.t Seq.r) -> t -> Scalar.t
+   val update : (Scalar.t Seq.r Seq.t -> Scalar.t Seq.r) -> t * Scalar.t -> t
+
+   val diag : Scalar.t -> t -> t Seq.t
+
+   val zero : t
+
+   val e : t Seq.t
+
+   val ~| : t UnOp.t
+
+   val |+| : t BinOp.t  val |+ : t * Scalar.t -> t  val +| : Scalar.t * t -> t
+   val |-| : t BinOp.t  val |- : t * Scalar.t -> t  val -| : Scalar.t * t -> t
+   val |*| : t BinOp.t  val |* : t * Scalar.t -> t  val *| : Scalar.t * t -> t
+   val |/| : t BinOp.t  val |/ : t * Scalar.t -> t  val /| : Scalar.t * t -> t
+
+   val |<=| : t BinPr.t
+   val |<|  : t BinPr.t
+   val |>=| : t BinPr.t
+   val |>|  : t BinPr.t
+
+   val minElems : t BinOp.t
+   val maxElems : t BinOp.t
+
+   val dot : t Sq.t -> Scalar.t
+   val norm : t -> Scalar.t
+   val mag : t -> Scalar.t
+   val invMag : t -> Scalar.t
+
+   val lerp : t Sq.t -> Scalar.t -> t
+   val nlerp : t Sq.t -> Scalar.t -> t
+
+   val normalize : t UnOp.t
+end
+
+signature VEC3 = sig
+   include VEC
+   structure Vec4 : VEC
+   val toXYZ : 'a Seq.t -> {x : 'a, y : 'a, z : 'a}
+   val fromXYZ : {x : 'a, y : 'a, z : 'a} -> 'a Seq.t
+   val cross : t BinOp.t
+   val toVec4 : Scalar.t -> t -> Vec4.t
+   val fromVec4 : Vec4.t -> t
+end


Property changes on: mltonlib/trunk/org/mlton/vesak/math3d/unstable/public/vec.sig
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the MLton-commit mailing list