math/vec3
src/math/vec3.tur
defn
vec3
(vec3 [x :float y :float z :float] :int)
construct a 3D vector.
Parameters
| x | x component | |
| y | y component | |
| z | z component |
Returns
Opaque :int handle to a heap-allocated Vec3.
Example
(vec3 1.0 2.0 3.0)
Since: P1
defn
v3-x
(v3-x [v :int] :float)
get x component. Since: P1
defn
v3-y
(v3-y [v :int] :float)
get y component. Since: P1
defn
v3-z
(v3-z [v :int] :float)
get z component. Since: P1
defn
v3-add
(v3-add [a :int b :int] :int)
add two Vec3 values. Since: P1
defn
v3-sub
(v3-sub [a :int b :int] :int)
subtract two Vec3 values. Since: P1
defn
v3-scale
(v3-scale [v :int s :float] :int)
scale a Vec3 by a scalar. Since: P1
defn
v3-dot
(v3-dot [a :int b :int] :float)
dot product of two Vec3 values. Since: P1
defn
v3-cross
(v3-cross [a :int b :int] :int)
cross product of two Vec3 values.
Returns
New Vec3 perpendicular to both a and b.
Example
(v3-cross (vec3 1.0 0.0 0.0) (vec3 0.0 1.0 0.0)) ; => (0, 0, 1)
Since: P1
defn
v3-length
(v3-length [v :int] :float)
Euclidean length of a Vec3. Since: P1
defn
v3-normalize
(v3-normalize [v :int] :int)
return a unit-length Vec3. Since: P1
defn
v3-lerp
(v3-lerp [a :int b :int t :float] :int)
linearly interpolate between two Vec3 values. Since: P1