Scad_ml.Vec33-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 endval zero : tZero 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 -> floatnorm 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 * 'bval get_x : t -> floatval get_y : t -> floatval get_z : t -> floatval to_string : t -> stringval to_vec2 : t -> float * floatval of_vec2 : (float * float) -> tval quaternion : Quaternion.t -> Vec3.t -> Vec3.tquaternion q t
Rotate t with the quaternion q.
val quaternion_about_pt : Quaternion.t -> Vec3.t -> Vec3.t -> Vec3.tquaternion_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.