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

# SCM Repository

[sml3d] Diff of /trunk/sml3d/src/base/common/vec3f.sml
 [sml3d] / trunk / sml3d / src / base / common / vec3f.sml

# Diff of /trunk/sml3d/src/base/common/vec3f.sml

revision 725, Fri Jan 22 02:27:14 2010 UTC revision 726, Fri Jan 22 02:37:06 2010 UTC
# Line 59  Line 59
59      fun dot ({x=x1, y=y1, z=z1} : vec3, {x=x2, y=y2, z=z2}) =      fun dot ({x=x1, y=y1, z=z1} : vec3, {x=x2, y=y2, z=z2}) =
60            (x1*x2 + y1*y2 +z1*z2)            (x1*x2 + y1*y2 +z1*z2)
61
62      fun lerp (v1, t, v2) = add(scale(1.0-t, v1), scale(t, v2))      fun lerp (v1, t, v2) = adds (scale(1.0-t, v1), t, v2)
63
64    (* spherical interpolation between unit vectors *)    (* spherical interpolation between unit vectors *)
65      fun slerp (v1, t, v2) = let      fun slerp (v1, t, v2) = let
# Line 69  Line 69
69                then let                then let
70                  val angle = Flt.acos cosAngle                  val angle = Flt.acos cosAngle
71                  val recipSinAngle = 1.0 / Flt.sin angle                  val recipSinAngle = 1.0 / Flt.sin angle
72                  val scale0 = recipSinAngle * Flt.sin((1.0 - t) * angle)                  val scale1 = recipSinAngle * Flt.sin((1.0 - t) * angle)
73                  val scale1 = recipSinAngle * Flt.sin(t * angle)                  val scale2 = recipSinAngle * Flt.sin(t * angle)
74                  in                  in