Module OgamlMath.Vector3fs

Operations on immutable vectors of 3 floats represented in spherical coordinates

This module defines the vector3fs type and various operations on it.

exception Vector3fs_exception of string
Raised when an error occurs (usually a division by zero)

Vector operations

type t = {r : float; t : float; p : float}
Type of immutable vectors of 3 floats represented in spherical coordinates

Record fields

r : float
Signed radius
t : float
Longitude (theta). A longitude of 0 corresponds to a vector pointing towards positive Z.
p : float
Latitude (phi). A latitude of 0 corresponds to a vector pointing towards the equator, and a latitude of pi/2 corresponds to a vector pointing towards the north pole (positive Y).
val zero : t
Zero vector
val unit_x : t
Unit x vector
val unit_y : t
Unit y vector
val unit_z : t
Unit z vector
val prop : float -> t -> t
Multiplies a vector by a scalar
val div : float -> t -> t
Divides a vector by a scalar. Raises Vector3fs_exception if the scalar is zero.
val to_cartesian : t -> Vector3f.t
Converts a vector represented in spherical coordinates to a vector represented in cartesian coordinates
See : OgamlMath.Vector3f
val from_cartesian : Vector3f.t -> t
Converts a vector represented in cartesian coordinates to a vector represented in spherical coordinates
See : OgamlMath.Vector3f
val norm : t -> float
Computes the norm of a vector
val normalize : t -> t
Normalizes a vector. Raises Vector3fs_exception if the vector is zero.
val print : t -> string
Returns a pretty-printed string (not for serialization)