Raised when an error occurs (usually a division by zero)
Module OgamlMath.Vector3f
Operations on immutable vectors of 3 floatsThis module defines the vector3f type and various operations on it.
Vector operations
Type of immutable vectors of 3 floats
Record fields
Fast way to create a vector
Zero vector
Unit x vector
Unit y vector
Unit z vector
Adds two vectors together
sub u v
computes the vector u - v
Multiplies a vector by a scalar
Divides a vector by a scalar. Raises Vector3f_exception if the scalar is zero.
Computes the pointwise product of two vectors.
Computes the pointwise division of two vectors.
Truncates the floating-point coordinates of a vector
See : OgamlMath.Vector3i
See : OgamlMath.Vector3i
Returns a float vector from an int vector
See : OgamlMath.Vector3i
See : OgamlMath.Vector3i
Computes the dot product of two vectors
Computes the cross product of two vectors
Computes the angle (in radians) between two vectors
Computes the squared norm of a vector
Computes the norm of a vector
Computes the squared distance between two points
Computes the distance between two points
Normalizes a vector. Raises Vector3f_exception if the vector is zero.
clamp v a b
returns the vector whose coordinates are the coordinates of v
clamped between the coordinates of a
and b
Maps each coordinate of a vector
Maps each pair of coordinates of two vectors
Returns the maximal coordinate of a vector
Returns the minimal coordinate of a vector
Returns a pretty-printed string (not for serialization)
direction u v
returns the normalized direction vector from u
to v
. Raises Vector3f_exception if u = v
.
endpoint a v t
returns the point a + tv
raytrace_points p1 p2
returns the list of integer-valued points (cubes) on the line from p1
to p2
Each point is a triple of the form
(t, p, f)
such that :t
is the time at the intersection between the line and the pointp
stores the (integer) coordinates of the pointf
is a unit vector indicating which face of the cube has been intersected
raytrace p v t
applies raytrace_points
between the points p
and p + tv
. The intersection times are comprised between 0 and t