Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
3-dimensional vector type.
In addition to basic math and vector operations, relevant transformation functions (and aliases) are mirroring those found in Scad
are provided. This allows for points in space represented by this type to moved around in a similar fashion to Scad.t
.
include module type of struct include Vec3 end
val zero : t
Zero vector = (0., 0., 0.)
horizontal_op f a b
Hadamard (element-wise) operation between vectors a
and b
using the function f
.
val norm : t -> float
norm t
Calculate the vector norm (a.k.a. magnitude) of t
.
distance a b
Calculate the magnitude of the difference (Hadamard subtraction) between a
and b
.
normalize t
Normalize t
to a vector for which the magnitude is equal to 1. e.g. norm (normalize t) = 1.
Equivalent to those found in Scad
. Quaternion operations are provided when this module is included in Scad_ml
.
rotate r t
Euler (xyz) rotation of t
by the angles in theta
. Equivalent to rotate_x rx t |> rotate_y ry |> rotate_z rz
, where (rx, ry, rz) = r
.
rotate_about_pt r pivot t
Translates t
along the vector pivot
, euler rotating the resulting vector with r
, and finally, moving back along the vector pivot
. Functionally, rotating about the point in space arrived at by the initial translation along the vector pivot
.
mirror ax t
Mirrors t
on a plane through the origin, defined by the normal vector ax
.
val map : (float -> 'b) -> t -> 'b * 'b * 'b
val get_x : t -> float
val get_y : t -> float
val get_z : t -> float
val to_string : t -> string
val to_vec2 : t -> float * float
val of_vec2 : (float * float) -> t
val quaternion : Quaternion.t -> Vec3.t -> Vec3.t
quaternion q t
Rotate t
with the quaternion q
.
val quaternion_about_pt : Quaternion.t -> Vec3.t -> Vec3.t -> Vec3.t
quaternion_about_pt q p t
Translates t
along the vector p
, rotating the resulting vector with the quaternion q
, and finally, moving back along the vector p
. Functionally, rotating about the point in space arrived at by the initial translation along the vector p
.