module Vector:Simple 3-dimensional vector. Example:sig..end
open FatCaml.Vector
let x = new vector 1.0 0.0 0.0 and
y = new vector 0.0 1.0 0.0 and
z = new vector 0.0 0.0 1.0 and
r = random_vector_3d () in
let xy = x#add y in
let long_xy = xy#scale 10.0 in
let norm_xy = long_xy#normalize in
print_string "norm_xy = " ;
norm_xy#print ;
print_newline () ;
let (a, b, c) = r#to_tuple in
if (new vector a b c)#eq r then
print_endline "Equality comparison works."
else
print_endline "Barf! equality comparison failed!"
Yeah, it's pretty basic.class vector :float -> float -> float ->object..end
val zero_vector : vectorval null_vector : vectorval x_axis_vector : vectorval y_axis_vector : vectorval z_axis_vector : vectorval pi : floatval deg2rad : float -> floatval rad2deg : float -> floatval tri_normal : < sub : 'a -> 'b; .. > ->
'a -> < sub : 'a -> < cross : 'b -> < normalize : 'c; .. >; .. >; .. > -> 'cval random_vector_3d : unit -> vector(for the non-mathematicly inclined: returns a speed between 0.0 and 1.0 in 3d space)
Call Random.self_init or equivelant before using this function.
val random_vector_2d : unit -> vectorVector.random_vector_3d but with a
zero Z component.