Module Vector


module Vector: sig .. end
Simple 3-dimensional vector. Example:

	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
A 3-dimensional vector.
val zero_vector : vector
Singleton of (0.0, 0.0, 0.0).
val null_vector : vector
Singleton of (nan, nan, nan).
val x_axis_vector : vector
Unit vector on the X axis.
val y_axis_vector : vector
Unit vector on the Y axis.
val z_axis_vector : vector
Unit vector on the Z axis.
val pi : float
And God said...
val deg2rad : float -> float
Degrees to radians.
val rad2deg : float -> float
Radians to degrees.
val tri_normal : < sub : 'a -> 'b; .. > ->
'a -> < sub : 'a -> < cross : 'b -> < normalize : 'c; .. >; .. >; .. > -> 'c
Returns a right-hand normal vector for the triangle.
val random_vector_3d : unit -> vector
Returns a vector whose magnitude is less than to 1.0 using the 'inside a sphere' method.

(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 -> vector
Returns a vector like Vector.random_vector_3d but with a zero Z component.