Module OgamlMath.Vector2fs

Operations on immutable vectors of 2 floats represented in polar coordinates

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

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

Vector operations

type t = {r : float; t : float}
Type of immutable vectors of 2 floats represented in polar coordinates

Record fields

r : float
Signed radius
t : float
Theta angle. An angle of 0 corresponds to a vector pointing towards positive X.
val zero : t
Zero vector
val unit_x : t
Unit x vector
val unit_y : t
Unit y vector
val prop : float -> t -> t
Multiplies a vector by a scalar
val div : float -> t -> t
Divides a vector by a scalar. Raises Vector2fs_exception if the scalar is zero.
val to_cartesian : t -> Vector2f.t
Converts a vector represented in polar coordinates to a vector represented in cartesian coordinates
See : OgamlMath.Vector2f
val from_cartesian : Vector2f.t -> t
Converts a vector represented in cartesian coordinates to a vector represented in polar coordinates
See : OgamlMath.Vector2f
val norm : t -> float
Computes the norm of a vector
val normalize : t -> t
Normalizes a vector. Raises Vector2fs_exception if the vector is zero.
val print : t -> string
Returns a pretty-printed string (not for serialization)