No matching definitions.

math/vec2

src/math/vec2.tur
defn

vec2

(vec2 [x : float y : float] :)

construct a 2D vector.

xx component
yy component

Opaque :int handle to a heap-allocated Vec2.

(vec2 1.0 2.0)

Since: P1

defn

v2-x

(v2-x [v : int] :)

get the x component.

defn

v2-y

(v2-y [v : int] :)

get the y component.

defn

v2-add

(v2-add [a : int b : int] :)

add two Vec2 values.

afirst vector
bsecond vector

New Vec2 representing a + b.

(v2-add (vec2 1.0 2.0) (vec2 3.0 4.0))  ; => (4.0, 6.0)

Since: P1

defn

v2-sub

(v2-sub [a : int b : int] :)

subtract two Vec2 values.

Since: P1

defn

v2-scale

(v2-scale [v : int s : float] :)

scale a Vec2 by a scalar.

vvector
sscalar factor

New Vec2 with each component multiplied by s.

(v2-scale (vec2 1.0 2.0) 3.0)  ; => (3.0, 6.0)

Since: P1

defn

v2-dot

(v2-dot [a : int b : int] :)

dot product of two Vec2 values.

Since: P1

defn

v2-length

(v2-length [v : int] :)

Euclidean length of a Vec2.

Since: P1

defn

v2-normalize

(v2-normalize [v : int] :)

return a unit-length Vec2.

Since: P1

defn

v2-lerp

(v2-lerp [a : int b : int t : float] :)

linearly interpolate between two Vec2 values.

astart vector
bend vector
tinterpolation factor (0.0=a, 1.0=b)

Since: P1