# rtg-math

A selection of the math routines most commonly needed for realtime graphics in lisp

Welcome to the rtg-math reference docs.

Please note that the .region* portion of the api is undocumented as it is still considered wip.

## Package Index

• ### RTG-MATH.VECTOR2(V2)

• #### ( DECF PLACE &OPTIONAL DELTA)

macro

Decrements the vec2 in 'place' by another vec2

• #### ( INCF PLACE &OPTIONAL DELTA)

macro

Increments the vec2 in 'place' by another vec2

• #### ( * &REST (VEC2S VEC2))

function

Takes any number of vec2 and performs component-wise multiplication on them returning a new vec2

• #### ( *S (VECTOR-A VEC2) (A SINGLE-FLOAT))

function

Component-wise multiplication of the vector by the scalar

• #### ( + &REST (VEC2S VEC2))

function

Takes any number of vec2 and performs component-wise addition on them returning a new vec2

• #### ( +S (VEC2 VEC2) (SCALAR SINGLE-FLOAT))

function

Component-wise add of single-float to vec2

• #### ( - (VEC2 VEC2) &REST (VEC2S VEC2))

function

Takes any number of vec2 and performs component-wise subtraction on them returning a new vec2

• #### ( -S (VEC2 VEC2) (SCALAR SINGLE-FLOAT))

function

Component-wise subtraction of single-float from vec2

• #### ( / (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Component-wise division of the two vec2

• #### ( /S (VECTOR-A VEC2) (A SINGLE-FLOAT))

function

Component-wise division of the vector by the scalar

• #### ( 0P (VECTOR-A VEC2))

function

Checks if the length of the vector is zero. As this is a floating point number it checks to see if the length is below a threshold set in the base-maths package

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Returns T if the two vectors are equal. Otherwise it returns nil.

• #### ( ABS (VECTOR-A VEC2))

function

Return a vec2 containing the abs of the original vec2's components.

• #### ( ABSOLUTE-DOT (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Return the absolute dot product of the vector-a and vector-b.

• #### ( ANGLE-BETWEEN (VEC-A VEC2) (VEC-B VEC2))

function

Returns the angle between two vec2s.

Equivilent to (abs (v2:angle-from a b))

• #### ( ANGLE-FROM (VEC-FROM VEC2) (VEC-TO VEC2))

function

Returns the signed angle between the two vec2s.

Positive angles are counter-clockwise

function

{TODO}

• #### ( COPY-VEC2 (VEC2 VEC2))

function

Returns a fresh vec2 which is v2:= to the orignal vector

• #### ( CROSS (VEC-A VEC2) (VEC-B VEC2))

function

Calculates the cross-product of 2 vec2s. This results in a single-float which is 2 times the area of the triangle.

• #### ( DISTANCE (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Return the distance between 2 points defined by vectors vector-a & vector-b. If comparing distances, use c-distance-squared as it desnt require a sqrt and thus is faster. If simply comparing distances then prefer the distance-squared function as the sqrt required here is (relatively) slow.

• #### ( DISTANCE-SQUARED (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Finds the squared distance between 2 points defined by vec2s vector-a & vector-b

distance is the square root of this value. The sqrt function is (relatively) slow so if all thats needs doing is to compare distances then prefer the distance-squared function

• #### ( DOT (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Return the dot product of vector-a and vector-b.

• #### ( FACE-FOREWARD (VECTOR-A VEC2) (VECTOR-B VEC2))

function

Returns vector-a if (> (v2:dot vector-a vector-b) 0) else returns (v2:negate vector-a)

• #### ( FROM-ANGLE (ANGLE SINGLE-FLOAT))

function

Makes a vec2 from an angle in radians.

Angle is in radians turning counterclockwise from (v! 0 1)

• #### ( FROM-COMPLEX (C COMPLEX))

function

Makes a vec2 from a complex. The realpart becomes the x component and the imagpart becomes the y component.

• #### ( LENGTH (VECTOR-A VEC2))

function

Returns the length of the vec2

If you only need to compare relative lengths then prefer the length-squared function as sqrt is a (relatively) slow operation.

• #### ( LENGTH-SQUARED (VECTOR-A VEC2))

function

Return the squared length of the vec2

length is the square root of this value. The sqrt function is (relatively slow so if all thats needs doing is to compare lengths then prefer the length-squared function

• #### ( LERP (VECTOR-A VEC2) (VECTOR-B VEC2) (AMMOUNT SINGLE-FLOAT))

function

Linearly interpolates between the two vec2s by the single-float amount

• #### ( MAKE (X SINGLE-FLOAT) (Y SINGLE-FLOAT))

function

This takes 2 single-floats and give back a vec2.

• #### ( NEGATE (VECTOR-A VEC2))

function

Return a vector that is the negated version of the vector passed in

• #### ( NORMALIZE (VECTOR-A VEC2))

function

This normalizes the given vec2.

function

{TODO}

• #### ( ROTATE (VEC VEC2) (ANGLE SINGLE-FLOAT))

function

Creates a new vec2 which is equivilent to the original once rotated counterclockwise by angle radians.

function

{TODO}

• #### ( UNITP (VECTOR-A VEC2))

function

Checks if the vector is of unit length. As this is a floating point number it checks to see if the length is within the range of 1 + or - and threshold set in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• ### RTG-MATH.VECTOR3(V3)

• #### ( DECF PLACE &OPTIONAL DELTA)

macro

Decrements the vec3 in 'place' by another vec3

• #### ( INCF PLACE &OPTIONAL DELTA)

macro

Increments the vec3 in 'place' by another vec3

• #### ( * &REST (VEC3S VEC3))

function

Takes any number of vec3 and performs component-wise multiplication on them returning a new vec3

• #### ( *S (VECTOR-A VEC3) (A SINGLE-FLOAT))

function

Component-wise multiplication of the vector by the scalar

• #### ( + &REST (VEC3S VEC3))

function

Takes any number of vec3 and performs component-wise addition on them returning a new vec3

• #### ( +S (VEC3 VEC3) (SCALAR SINGLE-FLOAT))

function

Component-wise add of single-float to vec3

• #### ( - (VEC3 VEC3) &REST (VEC3S VEC3))

function

Takes any number of vec3 and performs component-wise subtraction on them returning a new vec3

• #### ( -S (VEC3 VEC3) (SCALAR SINGLE-FLOAT))

function

Component-wise subtraction of single-float from vec3

• #### ( / (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Component-wise division of the two vec3

• #### ( /S (VECTOR-A VEC3) (A SINGLE-FLOAT))

function

Component-wise division of the vector by the scalar

• #### ( 0P (VECTOR-A VEC3))

function

Checks if the length of the vector is zero. As this is a floating point number it checks to see if the length is below a threshold set in the base-maths package

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Returns either t if the two vectors are equal. Otherwise it returns nil.

• #### ( ABS (VECTOR-A VEC3))

function

Return a vec3 containing the abs of the original vec3's components.

• #### ( ABSOLUTE-DOT (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Return the absolute dot product of the vector-a and vector-b.

function

{TODO}

• #### ( COPY-VEC3 (VEC3 VEC3))

function

Returns a fresh vec3 which is v3:= to the orignal vector

• #### ( CROSS (VEC-A VEC3) (VEC-B VEC3))

function

Calculates the cross-product of 2 vec3, i.e. the vector that lies perpendicular to them both. The resulting vec3 will not be normalized.

• #### ( DISTANCE (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Return the distance between 2 points defined by vectors vector-a & vector-b. If comparing distances, use c-distance-squared as it desnt require a sqrt and thus is faster. If simply comparing distances then prefer the distance-squared function as the sqrt required here is (relatively) slow.

• #### ( DISTANCE-SQUARED (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Finds the squared distance between 2 points defined by vec3s vector-a & vector-b

distance is the square root of this value. The sqrt function is (relatively) slow so if all thats needs doing is to compare distances then prefer the distance-squared function

• #### ( DOT (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Return the dot product of vector-a and vector-b.

• #### ( FACE-FOREWARD (VECTOR-A VEC3) (VECTOR-B VEC3))

function

Returns vector-a if (> (v3:dot vector-a vector-b) 0) else returns (v3:negate vector-a)

• #### ( LENGTH (VECTOR-A VEC3))

function

Returns the length of the vec3

If you only need to compare relative lengths then prefer the length-squared function as sqrt is a (relatively) slow operation.

• #### ( LENGTH-SQUARED (VECTOR-A VEC3))

function

Return the squared length of the vec3

length is the square root of this value. The sqrt function is (relatively slow so if all thats needs doing is to compare lengths then prefer the length-squared function

• #### ( LERP (VECTOR-A VEC3) (VECTOR-B VEC3) (AMMOUNT SINGLE-FLOAT))

function

Linearly interpolates between the two vec3s by the single-float amount

• #### ( MAKE (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT))

function

Make a vec3 from 3 single-floats

• #### ( NEGATE (VECTOR-A VEC3))

function

Return a vector that is the negated version of the vector passed in

• #### ( NORMALIZE (VECTOR-A VEC3))

function

This normalizes the given vec3.

• #### ( ROTATE (VEC VEC3) (ROTATION VEC3))

function

Creates a new vec3 which is equivilent to the original once rotated in each axis by the radians in the rotation vec3 provided.

function

{TODO}

• #### ( UNITP (VECTOR-A VEC3))

function

Checks if the vector is of unit length. As this is a floating point number it checks to see if the length is within the range of 1 + or - and threshold set in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• ### RTG-MATH.VECTOR4(V4)

• #### ( DECF PLACE &OPTIONAL DELTA)

macro

Decrements the vec4 in 'place' by another vec4

• #### ( INCF PLACE &OPTIONAL DELTA)

macro

Increments the vec4 in 'place' by another vec4

• #### ( * &REST (VEC4S VEC4))

function

Takes any number of vec4 and performs component-wise multiplication on them returning a new vec4

• #### ( *S (VECTOR-A VEC4) (A SINGLE-FLOAT))

function

Component-wise multiplication of the vector by the scalar

• #### ( + &REST (VEC4S VEC4))

function

Takes any number of vec4 and performs component-wise addition on them returning a new vec4

• #### ( +S (VEC4 VEC4) (SCALAR SINGLE-FLOAT))

function

Component-wise add of single-float to vec4

• #### ( - (VEC4 VEC4) &REST (VEC4S VEC4))

function

Takes any number of vec4 and performs component-wise subtraction on them returning a new vec4

• #### ( -S (VEC4 VEC4) (SCALAR SINGLE-FLOAT))

function

Component-wise subtraction of single-float from vec4

• #### ( / (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Component-wise division of the two vec4

• #### ( /S (VECTOR-A VEC4) (A SINGLE-FLOAT))

function

Component-wise division of the vector by the scalar

• #### ( 0P (VECTOR-A VEC4))

function

Checks if the length of the vector is zero. As this is a floating point number it checks to see if the length is below a threshold set in the base-maths package

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Returns either t if the two vectors are equal. Otherwise it returns nil.

• #### ( ABS (VECTOR-A VEC4))

function

Return a vec4 containing the abs of the original vec4's components.

• #### ( ABSOLUTE-DOT (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Return the absolute dot product of the vector-a and vector-b.

function

{TODO}

• #### ( COPY-VEC4 (VEC4 VEC4))

function

Returns a fresh vec4 which is v4:= to the orignal vector

• #### ( DISTANCE (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Return the distance between 2 points defined by vectors vector-a & vector-b. If comparing distances, use c-distance-squared as it desnt require a sqrt and thus is faster. If simply comparing distances then prefer the distance-squared function as the sqrt required here is (relatively) slow.

• #### ( DISTANCE-SQUARED (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Finds the squared distance between 2 points defined by vec4s vector-a & vector-b

distance is the square root of this value. The sqrt function is (relatively) slow so if all thats needs doing is to compare distances then prefer the distance-squared function

• #### ( DOT (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Return the dot product of vector-a and vector-b.

• #### ( FACE-FOREWARD (VECTOR-A VEC4) (VECTOR-B VEC4))

function

Returns vector-a if (> (v4:dot vector-a vector-b) 0) else returns (v4:negate vector-a)

• #### ( LENGTH (VECTOR-A VEC4))

function

Returns the length of the vec4

If you only need to compare relative lengths then prefer the length-squared function as sqrt is a (relatively) slow operation.

• #### ( LENGTH-SQUARED (VECTOR-A VEC4))

function

Return the squared length of the vec4

length is the square root of this value. The sqrt function is (relatively slow so if all thats needs doing is to compare lengths then prefer the length-squared function

• #### ( LERP (VECTOR-A VEC4) (VECTOR-B VEC4) (AMMOUNT SINGLE-FLOAT))

function

Linearly interpolates between the two vec4s by the single-float amount

• #### ( MAKE (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT) (W SINGLE-FLOAT))

function

Make a vec4 from 4 single-floats

• #### ( NEGATE (VECTOR-A VEC4))

function

Return a vector that is the negated version of the vector passed in

• #### ( NORMALIZE (VECTOR-A VEC4))

function

This normalizes the given vec4.

function

{TODO}

• #### ( UNITP (VECTOR-A VEC4))

function

Checks if the vector is of unit length. As this is a floating point number it checks to see if the length is within the range of 1 + or - and threshold set in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• ### RTG-MATH.VECTOR2.NON-CONSING(V2-N)

• #### ( * (ACCUM-VEC VEC2) &REST (VEC2S VEC2))

function

Destructively performs component-wise multiplication of the vec2s, the first vec2 is mutated.

• #### ( *S (VEC2 VEC2) (A SINGLE-FLOAT))

function

Destructively performs component-wise multiplication of the vec2 by the scalar

• #### ( + (ACCUM-VEC VEC2) &REST (VEC2S VEC2))

function

Destructively performs component-wise addition of the vec2s, the first vec2 is mutated.

• #### ( +S (VEC2 VEC2) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise add of single-float into the given vec2

• #### ( - (ACCUM-VEC VEC2) &REST (VEC2S VEC2))

function

Destructively performs component-wise substraction of the vec2s, the first vec2 is mutated.

• #### ( -S (VEC2 VEC2) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise subtraction of single-float from the given vec2

• #### ( / (VEC2-A VEC2) (VEC2-B VEC2))

function

Destructively performs component-wise division of the vec2s, the first vec2 is mutated

• #### ( /S (VEC2 VEC2) (A SINGLE-FLOAT))

function

Destructively performs component-wise division of the vec2 by the scalar

• #### ( NEGATE (VECTOR-A VEC2))

function

Destructively negates the given vector

• #### ( NORMALIZE (VECTOR-A VEC2))

function

Destructively normalizes the vector

• #### ( ROTATE (VEC VEC2) (ANGLE SINGLE-FLOAT))

function

Rotates the give vec2 counterclockwise by angle radians.

• #### ( SET-COMPONENTS (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (VEC VEC2))

function

Destructively updates of the components of the given vec2 to the new single-floats provided.

• ### RTG-MATH.VECTOR3.NON-CONSING(V3-N)

• #### ( * (ACCUM-VEC VEC3) &REST (VEC3S VEC3))

function

Destructively performs component-wise multiplication of the vec3s, the first vec3 is mutated.

• #### ( *S (VEC3 VEC3) (A SINGLE-FLOAT))

function

Destructively performs component-wise multiplication of the vec3 by the scalar

• #### ( + (ACCUM-VEC VEC3) &REST (VEC3S VEC3))

function

Destructively performs component-wise addition of the vec3s, the first vec3 is mutated.

• #### ( +S (VEC3 VEC3) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise add of single-float into the given vec3

• #### ( - (ACCUM-VEC VEC3) &REST (VEC3S VEC3))

function

Destructively performs component-wise substraction of the vec3s, the first vec3 is mutated.

• #### ( -S (VEC3 VEC3) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise subtraction of single-float from the given vec3

• #### ( / (VEC3-A VEC3) (VEC3-B VEC3))

function

Destructively performs component-wise division of the vec3s, the first vec3 is mutated

• #### ( /S (VEC3 VEC3) (A SINGLE-FLOAT))

function

Destructively performs component-wise division of the vec3 by the scalar

• #### ( NEGATE (VECTOR-A VEC3))

function

Destructively negates the given vector

• #### ( NORMALIZE (VECTOR-A VEC3))

function

Destructively normalizes the vector

• #### ( ROTATE (VEC VEC3) (ROTATION VEC3))

function

Rotates the given vec3 counterclockwise by the radians in the rotation vec3 provided.

• #### ( SET-COMPONENTS (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT) (VEC VEC3))

function

Destructively updates of the components of the given vec3 to the new single-floats provided.

• ### RTG-MATH.VECTOR4.NON-CONSING(V4-N)

• #### ( * (ACCUM-VEC VEC4) &REST (VEC4S VEC4))

function

Destructively performs component-wise multiplication of the vec4s, the first vec4 is mutated.

• #### ( *S (VEC4 VEC4) (A SINGLE-FLOAT))

function

Destructively performs component-wise multiplication of the vec4 by the scalar

• #### ( + (ACCUM-VEC VEC4) &REST (VEC4S VEC4))

function

Destructively performs component-wise addition of the vec4s, the first vec4 is mutated.

• #### ( +S (VEC4 VEC4) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise add of single-float into the given vec2

• #### ( - (ACCUM-VEC VEC4) &REST (VEC4S VEC4))

function

Destructively performs component-wise substraction of the vec4s, the first vec4 is mutated.

• #### ( -S (VEC4 VEC4) (SCALAR SINGLE-FLOAT))

function

Destructive Component-wise subtraction of single-float from the given vec2

• #### ( / (VEC4-A VEC4) (VEC4-B VEC4))

function

Destructively performs component-wise division of the vec4s, the first vec4 is mutated

• #### ( /S (VEC4 VEC4) (A SINGLE-FLOAT))

function

Destructively performs component-wise division of the vec4 by the scalar

• #### ( NEGATE (VECTOR-A VEC4))

function

Destructively negates the given vector

• #### ( NORMALIZE (VECTOR-A VEC4))

function

Destructively normalizes the vector

• #### ( SET-COMPONENTS (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT) (W SINGLE-FLOAT) (VEC VEC4))

function

Destructively updates of the components of the given vec2 to the new single-floats provided.

• ### RTG-MATH.VECTORS(V)

• #### ( DECF PLACE &OPTIONAL DELTA)

macro

Decrements the vector in 'place' by another vector of the same kind

• #### ( INCF PLACE &OPTIONAL DELTA)

macro

Increments the vector in 'place' by another vector of the same kind

• #### ( * VEC-A SCALAR-OR-VEC)

function

Adds two vectors together and returns the result as a new vector of the same type

• #### ( + &REST VECS)

function

Adds 'n' vec2, vec3 or vec4 together, returning a new vector of the same kind.

• #### ( +S VEC SCALAR)

function

Componentwise addition of the given scalar to the components of the vec2, vec3 or vec4 provided. Returns a new vector of the same kind.

• #### ( - &REST VECS)

function

Subtracts 'n' vec2, vec3 or vec4 from each other, returning a new vector of the same kind.

• #### ( -S VEC SCALAR)

function

Componentwise subtractiong of the given scalar from the components of the vec2, vec3 or vec4 provided. Returns a new vector of the same kind.

• #### ( / VEC-A SCALAR-OR-VEC)

function

Divides the given vec2, vec3 or vec4 by the scalar or vector provided.

If a vector is provided it must be of the same kind as vec-a and the division is performed component-wise.

• #### ( /= &REST VECS)

function

Returns either t if the two vectors are equal. Otherwise it returns nil.

• #### ( 0P VEC-A)

function

Returns t if the vector is of zero length

• #### ( = &REST VECS)

function

Returns either t if the vectors are equal. Otherwise it returns nil.

• #### ( ABSOLUTE-DOT VEC-A VEC-B)

function

Adds two vectors together and returns the result as a new vector of the same type

function

{TODO}

• #### ( CROSS VEC-A VEC-B)

function

Calculates the cross-product of 2 vectors, i.e. the vector that lies perpendicular to them both. The resulting vector will not be normalized.

• #### ( DISTANCE VEC-A VEC-B)

function

Return the distance between 2 points defined by vectors vector-a & vector-b. If comparing distances, use c-distance-squared as it desnt require a sqrt and thus is faster.

• #### ( DISTANCE-SQUARED VEC-A VEC-B)

function

Returns the squared distance between 2 points defined by vectors vector-a & vector-b

• #### ( DOT VEC-A VEC-B)

function

Returns the dot product of the 2 given vectors.

• #### ( FACE-FOREWARD VEC-A VEC-B)

function

Returns vector-a if (> (v3:dot vector-a vector-b) 0) else returns (v3:negate vector-a)

• #### ( LENGTH VEC-A)

function

Returns the length of a vector If you only need to compare relative lengths then definately stick to length-squared as the sqrt is a slow operation.

• #### ( LENGTH-SQUARED VEC-A)

function

Finds the squared distance between 2 points defined by vectors vector-a & vector-b

• #### ( LERP VECTOR-A VECTOR-B AMMOUNT)

function

Linearly interpolates between the two vectors by the given amount. Returns a new vector of the same kind.

• #### ( MERGE-INTO-VECTOR &REST VECTORS)

function

Takes a list of vectors and combines them into a new vector

• #### ( MIX VECTOR-A VECTOR-B AMMOUNT)

function

Linearly interpolates between the two vectors by the given amount. Returns a new vector of the same kind.

• #### ( NEGATE VEC)

function

Negates the given vector. Returns a new vector of the same kind.

• #### ( NORMALIZE VEC-A)

function

Normalizes the vector. Returns a new vector of the same kind.

function

{TODO}

• #### ( SWIZZLE VEC PATTERN)

function

Swizzle allows you to compose a new vector out of an existing one by picking it's components.

Given a vec3 called a = (v! 1 2 3)

• #### ( S~ VEC PATTERN)

function

Shorthand for swizzle

s~ allows you to compose a new vector out of an existing one by picking it's components.

Given a vec3 called a = (v! 1 2 3)

• (s~ a :xy) → (v! 1 2)
• (s~ a :xx) → (v! 1 1)
• (s~ a :yx) → (v! 2 1)
• (s~ a :yyyy) → (v! 2 2 2 2)
• (s~ a :zzyy) → (v! 3 3 2 2)
• #### ( UNITP VEC-A)

function

Returns T is the given vector has a length eql to 1

• #### ( W VEC)

function

Returns the w component of the vector

• #### ( X VEC)

function

Returns the x component of the vector

• #### ( Y VEC)

function

Returns the y component of the vector

• #### ( Z VEC)

function

Returns the z component of the vector

• ### RTG-MATH.MATRIX2(M2)

• #### ( * &REST (MATRICES MAT2))

function

Takes any number of mat2s and multiplies them together returning a new mat2.

• #### ( *S (MAT-A MAT2) (SCALAR SINGLE-FLOAT))

function

Multiplies the components of the mat2 by the scalar provided

• #### ( *V (MAT-A MAT2) (VEC-A VEC2))

function

Multiplies the vec2 by the mat2 and returns the result as a new vec2

• #### ( + (MAT-A MAT2) (MAT-B MAT2))

function

Adds the 2 matrices component wise and returns the result as a new mat2

• #### ( - (MAT-A MAT2) (MAT-B MAT2))

function

Subtracts the 2 matrices component wise and returns the result as a new mat2

• #### ( 0! )

function

Return a mat2 where all components are zero

• #### ( 0P (MAT-A MAT2))

function

Returns T if this is a zero matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (MAT-A MAT2) (MAT-B MAT2))

function

Returns T if all elements of both matrices provided are equal

• #### ( ADJOINT (MAT-A MAT2))

function

Returns the adjoint of the provided matrix

• #### ( COPY-MAT2 (MAT2 MAT2))

function

Returns a fresh mat2 which is m2:= to the orignal matrix

• #### ( FROM-COLUMNS (COL-1 VEC2) (COL-2 VEC2))

function

Make a mat2 using the data in the 2 vec2s to populate the columns

• #### ( FROM-ROWS (ROW-1 VEC2) (ROW-2 VEC2))

function

Make a mat2 using the data in the 2 vec2s to populate the rows

• #### ( GET-COLUMN (MAT-A MAT2) (COL-NUM (INTEGER 0 1)))

function

Return the specified column of the matrix as a vec2

• #### ( GET-COLUMNS (MAT-A MAT2))

function

Return the columns of the matrix as 2 vec2s

• #### ( GET-ROW (MAT-A MAT2) (ROW-NUM (INTEGER 0 1)))

function

Return the specified row of the matrix as a vec2

• #### ( GET-ROWS (MAT-A MAT2))

function

Return the rows of the matrix as 2 vec2s

• #### ( IDENTITY )

function

Return a mat2 identity matrix

• #### ( IDENTITYP (MAT-A MAT2))

function

Returns T if this is an identity matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( MAKE (A SINGLE-FLOAT) (B SINGLE-FLOAT) (C SINGLE-FLOAT) (D SINGLE-FLOAT))

function

Make a mat2. Data must be provided in row major order

• #### ( MELM (MAT-A MAT2) (ROW (INTEGER 0 1)) (COL (INTEGER 0 1)))

function

Provides access to data in the matrix by row and column number. The actual data is stored in a 1d list in column major order, but this abstraction means we only have to think in row major order which is how most mathematical texts and online tutorials choose to show matrices

function

{TODO}

• #### ( NEGATE (MAT-A MAT2))

function

Negates the components of the mat2

• #### ( ROTATION-FROM-EULER (ANGLE SINGLE-FLOAT))

function

Creates a rotation mat2 which represents a anticlockwise rotation.

The angle is specified in radians

• #### ( SCALE (SCALE-VEC2 VEC2))

function

Returns a matrix which will scale by the amounts specified

• #### ( TRACE (MAT-A MAT2))

function

Returns the trace of the matrix (That is the diagonal values)

• #### ( TRANSPOSE (MAT-A MAT2))

function

Returns the transpose of the provided matrix

• ### RTG-MATH.MATRIX3(M3)

• #### ( * &REST (MATRICES MAT3))

function

Takes any number of mat3s and multiplies them together returning a new mat3.

• #### ( *S (MAT-A MAT3) (SCALAR SINGLE-FLOAT))

function

Multiplies the components of the mat3 by the scalar provided

• #### ( *V (MAT-A MAT3) (VEC-A VEC3))

function

Multiplies the vec3 by the mat3 and returns the result as a new vec3

• #### ( + (MAT-A MAT3) (MAT-B MAT3))

function

Adds the 2 matrices component wise and returns the result as a new mat3

• #### ( - (MAT-A MAT3) (MAT-B MAT3))

function

Subtracts the 2 matrices component wise and returns the result as a new mat3

• #### ( 0! )

function
No docstring provided.
• #### ( 0P (MAT-A MAT3))

function

Returns T if this is a zero matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (MAT-A MAT3) (MAT-B MAT3))

function

Returns T if all elements of both matrices provided are equal

• #### ( ADJOINT (MAT-A MAT3))

function

Returns the adjoint of the provided matrix

• #### ( AFFINE-INVERSE (MAT-A MAT3))

function

returns the inverse of the mat3

• #### ( COPY-MAT3 (MAT3 MAT3))

function

Returns a fresh mat3 which is m3:= to the orignal matrix

• #### ( DETERMINANT (MAT-A MAT3))

function

Returns the determinant of the mat3 (uses the cramer method)

• #### ( FROM-COLUMNS (COL-1 VEC3) (COL-2 VEC3) (COL-3 VEC3))

function

Make a mat3 using the data in the 3 vec3s to populate the columns

• #### ( FROM-DIRECTION (UP3 VEC3) (DIR3 VEC3))

function

Creates a mat3 that would rotate the vector (v! 0 0 -1) to point in the given direction.

• #### ( FROM-ROWS (ROW-1 VEC3) (ROW-2 VEC3) (ROW-3 VEC3))

function

Make a mat3 using the data in the 3 vec3s to populate the rows

• #### ( GET-AXIS-ANGLE (MAT-A MAT3))

function

Gets one possible axis-angle pair that will generate this mat3.

Assumes that this is a rotation matrix. It is critical that this is true (and elements are between -1f0 and 1f0) as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( GET-COLUMN (MAT-A MAT3) (COL-NUM (INTEGER 0 3)))

function

Return the specified column of the matrix as a vec3

• #### ( GET-COLUMNS (MAT-A MAT3))

function

Return the columns of the matrix as 3 vec3s

• #### ( GET-FIXED-ANGLES (MAT-A MAT3))

function

Gets one set of possible z-y-x fixed angles that will generate this mat3.

Assumes that this is a rotation matrix. It is critical that this is true (and elements are between -1f0 and 1f0) as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( GET-ROW (MAT-A MAT3) (ROW-NUM (INTEGER 0 3)))

function

Return the specified row of the matrix as a vec3

• #### ( GET-ROWS (MAT-A MAT3))

function

Return the rows of the matrix as 3 vec3s

• #### ( IDENTITY )

function

Return a mat3 identity matrix

• #### ( IDENTITYP (MAT-A MAT3))

function

Returns T if this is an identity matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( LOOK-AT (UP3 VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Creates a mat3 that would rotate the vector (v! 0 0 -1) to point in the direction from from3 to to3

• #### ( MAKE (A SINGLE-FLOAT) (B SINGLE-FLOAT) (C SINGLE-FLOAT) (D SINGLE-FLOAT) (E SINGLE-FLOAT) (F SINGLE-FLOAT) (G SINGLE-FLOAT) (H SINGLE-FLOAT) (I SINGLE-FLOAT))

function

Make a mat3. Data must be provided in row major order

• #### ( MELM (MAT-A MAT3) (ROW (INTEGER 0 2)) (COL (INTEGER 0 2)))

function

Provides access to data in the matrix by row and column number. The actual data is stored in a 1d list in column major order, but this abstraction means we only have to think in row major order which is how most mathematical texts and online tutorials choose to show matrices

function

{TODO}

• #### ( NEGATE (MAT-A MAT3))

function

Negates the components of the mat3

• #### ( POINT-AT (UP VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Create the mat3 rotation portion to a 'world to view' 'look-at' matrix

• #### ( ROTATION-FROM-AXIS-ANGLE (AXIS3 VEC3) (ANGLE SINGLE-FLOAT))

function

Returns a mat3 which will rotate a point about the axis specified by the angle provided

• #### ( ROTATION-FROM-EULER (VEC3-A VEC3))

function

Creates a rotation mat3 which represents a anticlockwise rotation.

The angle is specified in radians

• #### ( ROTATION-X (ANGLE SINGLE-FLOAT))

function

Returns a mat3 which would rotate a point around the x axis by the specified amount

• #### ( ROTATION-Y (ANGLE SINGLE-FLOAT))

function

Returns a mat3 which would rotate a point around the y axis by the specified amount

• #### ( ROTATION-Z (ANGLE SINGLE-FLOAT))

function

Returns a mat3 which would rotate a point around the z axis by the specified amount

• #### ( SCALE (SCALE-VEC3 VEC3))

function

Returns a matrix which will scale by the amounts specified

• #### ( TRACE (MAT-A MAT3))

function

Returns the trace of the matrix (That is the diagonal values)

• #### ( TRANSPOSE (MAT-A MAT3))

function

Returns the transpose of the provided matrix

• ### RTG-MATH.MATRIX4(M4)

• #### ( * &REST (MATRICES MAT4))

function

Takes any number of mat4s and multiplies them together returning a new mat4.

• #### ( *S (MAT-A MAT4) (SCALAR SINGLE-FLOAT))

function

Multiplies the components of the mat4 by the scalar provided

• #### ( *V (MAT-A MAT4) (VEC4 VEC4))

function

Multiplies the vec4 by the mat4 and returns the result as a new vec4

• #### ( *V3 (MAT-A MAT4) (VEC3 VEC3))

function

Multiplies the vec3 by the mat3 and returns the result as a new vec3

• #### ( + (MAT-A MAT4) (MAT-B MAT4))

function

Adds the 2 matrices component wise and returns the result as a new mat4

• #### ( - (MAT-A MAT4) (MAT-B MAT4))

function

Subtracts the 2 matrices component wise and returns the result as a new mat4

• #### ( 0! )

function

Return a mat4 where every component is 0

• #### ( 0P (MAT-A MAT4))

function

Returns T if this is a zero matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( = (MAT-A MAT4) (MAT-B MAT4))

function

Returns T if all elements of both matrices provided are equal

• #### ( ADJOINT (MAT-A MAT4))

function

Returns the adjoint of the provided matrix

• #### ( AFFINE-INVERSE (MAT-A MAT4))

function

returns the inverse of the mat4

• #### ( COPY-MAT4 (MAT4 MAT4))

function

Returns a fresh mat4 which is m4:= to the orignal matrix

• #### ( DETERMINANT (MAT-A MAT4))

function

Returns the determinant of the mat4

• #### ( FROM-COLUMNS (COL-1 VEC4) (COL-2 VEC4) (COL-3 VEC4) (COL-4 VEC4))

function

Make a mat4 using the data in the 4 vec4s to populate the columns

• #### ( FROM-COLUMNS-V3 (COL-1 VEC3) (COL-2 VEC3) (COL-3 VEC3))

function

Make a mat4 using the data in the 3 vec3s provided to populate the columns.

The 4th row & column are filled as an identity matrix would be.

• #### ( FROM-DIRECTION (UP3 VEC3) (DIR3 VEC3))

function

Creates a mat4 that would rotate the vector (v! 0 0 -1) to face in the given direction.

• #### ( FROM-MAT3 (M-A MAT3))

function

Takes a mat3 and returns a mat4 rotation matrix with the same values.

The 4th row & column are filled as an identity matrix would be.

• #### ( FROM-ROWS (ROW-1 VEC4) (ROW-2 VEC4) (ROW-3 VEC4) (ROW-4 VEC4))

function

Make a mat4 using the data in the 4 vec4s to populate the rows

• #### ( FROM-ROWS-V3 (ROW-1 VEC3) (ROW-2 VEC3) (ROW-3 VEC3))

function

Make a mat4 using the data in the 3 vec3s provided to populate the rows.

The 4th row & column are filled as an identity matrix would be.

• #### ( GET-AXIS-ANGLE (MAT-A MAT4))

function

Gets one possible axis-angle pair that will generate this mat4.

Assumes that this is a rotation matrix. It is critical that this is true (and elements are between -1f0 and 1f0) as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( GET-COLUMN (MAT-A MAT4) (COL-NUM (INTEGER 0 3)))

function

Return the specified column of the matrix as a vec4

• #### ( GET-COLUMNS (MAT-A MAT4))

function

Return the columns of the matrix as 4 vec4s

• #### ( GET-FIXED-ANGLES (MAT-A MAT4))

function

Gets one set of possible z-y-x fixed angles that will generate this mat4.

Assumes that this is a rotation matrix. It is critical that this is true (and elements are between -1f0 and 1f0) as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( GET-ROW (MAT-A MAT4) (ROW-NUM (INTEGER 0 3)))

function

Return the specified row of the matrix as a vec4

• #### ( GET-ROWS (MAT-A MAT4))

function

Return the rows of the matrix as 4 vec4s

• #### ( IDENTITY )

function

Return a mat4 identity matrix

• #### ( IDENTITYP (MAT-A MAT4))

function

Returns T if this is an identity matrix

As contents of the matrix are floats the values have an error bound as defined in base-maths

Note: Old, float epsilons are tricky, I have a ticket open to review this

• #### ( INVERSE (MATRIX MAT4))

function

Inverts the matrix.

• #### ( LOOK-AT (UP3 VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Creates a mat4 that would rotate the vector (v! 0 0 -1) to point in the direction from from3 to to3

• #### ( MAKE (A SINGLE-FLOAT) (B SINGLE-FLOAT) (C SINGLE-FLOAT) (D SINGLE-FLOAT) (E SINGLE-FLOAT) (F SINGLE-FLOAT) (G SINGLE-FLOAT) (H SINGLE-FLOAT) (I SINGLE-FLOAT) (J SINGLE-FLOAT) (K SINGLE-FLOAT) (L SINGLE-FLOAT) (M SINGLE-FLOAT) (N SINGLE-FLOAT) (O SINGLE-FLOAT) (P SINGLE-FLOAT))

function

Make a mat4. Data must be provided in row major order

• #### ( MELM (MAT-A MAT4) (ROW (INTEGER 0 3)) (COL (INTEGER 0 3)))

function

Provides access to data in the matrix by row and column number. The actual data is stored in a 1d list in column major order, but this abstraction means we only have to think in row major order which is how most mathematical texts and online tutorials choose to show matrices

• #### ( MINOR (MAT-A MAT4) (ROW-0 (INTEGER 0 3)) (ROW-1 (INTEGER 0 3)) (ROW-2 (INTEGER 0 3)) (COL-0 (INTEGER 0 3)) (COL-1 (INTEGER 0 3)) (COL-2 (INTEGER 0 3)))

function

Returns the minor of the matrix

function

{TODO}

• #### ( NEGATE (MAT-A MAT4))

function

Negates the components of the mat4

• #### ( POINT-AT (UP VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Create the mat4 rotation portion to a 'world to view' 'look-at' matrix

• #### ( ROTATION-FROM-AXIS-ANGLE (AXIS3 VEC3) (ANGLE SINGLE-FLOAT))

function

Returns a mat4 which will rotate a point about the axis specified by the angle provided

• #### ( ROTATION-FROM-EULER (VEC3-A VEC3))

function

Creates a rotation mat4 which represents a anticlockwise rotation.

The angle is specified in radians

• #### ( ROTATION-FROM-MAT3 (M-A MAT3))

function

Takes a mat3 rotation matrix and returns a mat4 rotation matrix with the same values. The 4th row & column are filled as an identity matrix would be.

• #### ( ROTATION-X (ANGLE SINGLE-FLOAT))

function

Returns a mat4 which would rotate a point around the x axis by the specified amount

• #### ( ROTATION-Y (ANGLE SINGLE-FLOAT))

function

Returns a mat4 which would rotate a point around the y axis by the specified amount

• #### ( ROTATION-Z (ANGLE SINGLE-FLOAT))

function

Returns a mat4 which would rotate a point around the z axis by the specified amount

• #### ( SCALE (SCALE-VEC3 VEC3))

function

Returns a matrix which will scale by the amounts specified

• #### ( TO-MAT3 (MAT4 MAT4))

function

Returns a fresh mat3 which contains the 'top left' 3x3 portion of the given mat4

• #### ( TRACE (MAT-A MAT4))

function

Returns the trace of the matrix (That is the diagonal values)

• #### ( TRANSLATION (VEC-A (SIMPLE-ARRAY SINGLE-FLOAT)))

function

Takes a vec3 and returns a mat4 which will translate by the specified amount

• #### ( TRANSPOSE (M-A MAT4))

function

Returns the transpose of the provided matrix

• ### RTG-MATH.MATRIX2.NON-CONSING(M2-N)

• #### ( * (ACCUM-MAT MAT2) &REST (MAT2S MAT2))

function

Takes any number of mat2s and multiplies them together destructively writing the result into the first mat2.

• #### ( *S (MAT-TO-MUTATE MAT2) (SCALAR SINGLE-FLOAT))

function
No docstring provided.
• #### ( *V (MAT-A MAT2) (VEC2-TO-MUTATE VEC2))

function

Destructively multiplies the vec3 by the mat2 and returning the mutated vec3

• #### ( + (MAT-ACCUM MAT2) (MAT-B MAT2))

function

Add the second mat2 component wise to the first and return the first

• #### ( - (MAT-ACCUM MAT2) (MAT-B MAT2))

function

Subtracts the second mat2 component wise from the first and return the first

• #### ( ADJOINT (MAT-TO-MUTATE MAT2))

function

Mutates the given mat2 to be it's own adjoint

function

{TODO}

• #### ( NEGATE (MAT-TO-NEGATE MAT2))

function

Negates the components of the mat2

• #### ( SET-COMPONENTS (C00 SINGLE-FLOAT) (C01 SINGLE-FLOAT) (C10 SINGLE-FLOAT) (C11 SINGLE-FLOAT) (MAT2-TO-MUTATE MAT2))

function

Destructively updates of the components of the given mat2 to the new single-floats provided.

• #### ( SET-FROM-COLUMNS (MAT-TO-MUTATE MAT2) (COL-1 VEC2) (COL-2 VEC2))

function

Destructively updates of the components of the given mat2 using the 2 vec2s provided to populate the columns

• #### ( SET-FROM-ROWS (MAT-TO-MUTATE MAT2) (ROW-1 VEC2) (ROW-2 VEC2))

function

Destructively updates of the components of the given mat2 using the 2 vec2s provided to populate the rows

• #### ( SET-FROM-SCALE (MAT-TO-MUTATE MAT2) (SCALE-VEC2 VEC2))

function

Mutates the given mat2 to be a which will scale by the amounts specified

• #### ( SET-ROTATION-FROM-EULER (MAT-TO-MUTATE MAT2) (ANGLE SINGLE-FLOAT))

function

Destructively modifies the mat2 to be a rotation matrix whos rotation angle comes from the single-float provided.

• #### ( TRANSPOSE (MAT-TO-TRANSPOSE MAT2))

function

Mutates the given mat2 to be it's own transpose

• ### RTG-MATH.MATRIX3.NON-CONSING(M3-N)

• #### ( * (ACCUM-MAT MAT3) &REST (MAT3S MAT3))

function

Takes any number of mat3s and multiplies them together destructively writing the result into the first mat3.

• #### ( *S (MAT-TO-MUTATE MAT3) (SCALAR SINGLE-FLOAT))

function

Multiplies the components of the mat4 by the scalar provided

• #### ( *V (MAT-A MAT3) (VEC3-TO-MUTATE VEC3))

function

Destructively multiplies the vec3 by the mat3 and returning the mutated vec3

• #### ( + (MAT-ACCUM MAT3) (MAT-B MAT3))

function

Add the second mat3 component wise to the first and return the first

• #### ( - (MAT-ACCUM MAT3) (MAT-B MAT3))

function

Subtracts the second mat3 component wise from the first and return the first

• #### ( ADJOINT (MAT-TO-MUTATE MAT3))

function

Mutates the given mat3 to be it's own adjoint

• #### ( AFFINE-INVERSE (MAT-TO-INVERT MAT3))

function

Mutates the given mat3 to be it's own inverse

function

{TODO}

• #### ( NEGATE (MAT-TO-NEGATE MAT3))

function

Negates the components of the mat3

• #### ( SET-COMPONENTS (C00 SINGLE-FLOAT) (C01 SINGLE-FLOAT) (C02 SINGLE-FLOAT) (C10 SINGLE-FLOAT) (C11 SINGLE-FLOAT) (C12 SINGLE-FLOAT) (C20 SINGLE-FLOAT) (C21 SINGLE-FLOAT) (C22 SINGLE-FLOAT) (MAT3-TO-MUTATE MAT3))

function

Destructively updates of the components of the given mat3 to the new single-floats provided.

• #### ( SET-FROM-COLUMNS (MAT-TO-MUTATE MAT3) (COL-1 VEC3) (COL-2 VEC3) (COL-3 VEC3))

function

Destructively updates of the components of the given mat3 using the 3 vec3s provided to populate the columns

• #### ( SET-FROM-ROTATION-X (MAT-TO-MUTATE MAT3) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat3 making it a matrix which would rotate a point around the x axis by the specified amount

• #### ( SET-FROM-ROTATION-Y (MAT-TO-MUTATE MAT3) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat3 making it a matrix which would rotate a point around the y axis by the specified amount

• #### ( SET-FROM-ROTATION-Z (MAT-TO-MUTATE MAT3) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat3 making it a matrix which would rotate a point around the z axis by the specified amount

• #### ( SET-FROM-ROWS (MAT-TO-MUTATE MAT3) (ROW-1 VEC3) (ROW-2 VEC3) (ROW-3 VEC3))

function

Destructively updates of the components of the given mat3 using the 3 vec3s provided to populate the rows

• #### ( SET-FROM-SCALE (MAT-TO-MUTATE MAT3) (SCALE-VEC3 VEC3))

function

Mutates the given mat3 to be a matrix which will scale by the amounts specified

• #### ( SET-ROTATION-FROM-AXIS-ANGLE (MAT-TO-MUTATE MAT3) (AXIS3 VEC3) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat3 making it a matrix which will rotate a point about the axis specified by the angle provided

• #### ( SET-ROTATION-FROM-EULER (MAT-TO-MUTATE MAT3) (VEC3-A VEC3))

function

Destructively modifies the mat3 to be a rotation matrix whos rotation angles come from the vec3 provided.

• #### ( TRANSPOSE (MAT-TO-TRANSPOSE MAT3))

function

Mutates the given mat3 to be it's own transpose

• ### RTG-MATH.MATRIX4.NON-CONSING(M4-N)

• #### ( * (ACCUM-MAT MAT4) &REST (MAT4S MAT4))

function

Takes any number of mat4s and multiplies them together destructively writing the result into the first mat4.

• #### ( *S (MAT-TO-MUTATE MAT4) (SCALAR SINGLE-FLOAT))

function

Destructively performs component-wise multiplication of the vec3 by the scalar

• #### ( *V (MAT-A MAT4) (VEC4-TO-MUTATE VEC4))

function

Destructively multiplies the vec3 by the top left 3x3 portion of the mat4 returning the mutated vec3

• #### ( *V3 (MAT-A MAT4) (VEC3-TO-MUTATE VEC3))

function
No docstring provided.
• #### ( + (MAT-ACCUM MAT4) (MAT-B MAT4))

function

Add the second mat4 component wise to the first and return the first

• #### ( - (MAT-ACCUM MAT4) (MAT-B MAT4))

function

Subtracts the second mat4 component wise from the first and return the first

• #### ( ADJOINT (MAT-TO-MUTATE MAT4))

function

Mutates the given mat4 to be it's own adjoint

• #### ( AFFINE-INVERSE (MAT-TO-INVERT MAT4))

function

Mutates the given mat4 to be it's own inverse

function

{TODO}

• #### ( NEGATE (MAT-TO-NEGATE MAT4))

function

Negates the components of the mat4

• #### ( SET-COMPONENTS (C00 SINGLE-FLOAT) (C01 SINGLE-FLOAT) (C02 SINGLE-FLOAT) (C03 SINGLE-FLOAT) (C10 SINGLE-FLOAT) (C11 SINGLE-FLOAT) (C12 SINGLE-FLOAT) (C13 SINGLE-FLOAT) (C20 SINGLE-FLOAT) (C21 SINGLE-FLOAT) (C22 SINGLE-FLOAT) (C23 SINGLE-FLOAT) (C30 SINGLE-FLOAT) (C31 SINGLE-FLOAT) (C32 SINGLE-FLOAT) (C33 SINGLE-FLOAT) (MAT4-TO-MUTATE MAT4))

function

Destructively updates of the components of the given mat4 to the new single-floats provided.

• #### ( SET-FROM-COLUMNS (MAT-TO-MUTATE MAT4) (COL-1 VEC4) (COL-2 VEC4) (COL-3 VEC4) (COL-4 VEC4))

function

Destructively updates of the components of the given mat4 using the 4 vec4s provided to populate the columns

• #### ( SET-FROM-COLUMNS-V3 (MAT-TO-MUTATE MAT4) (COL-1 VEC3) (COL-2 VEC3) (COL-3 VEC3))

function

Make a mat4 using the data in the 3 vec3 provided to populate the columns

The 4th row & column is filled as an identity matrix would be.

• #### ( SET-FROM-MAT3 (MAT-TO-MUTATE MAT4) (M-A MAT3))

function

Destructively updates of the components of the given mat4 making it's top left 3x3 portion the same as the mat3 provided.

The 4th row & column is filled as an identity matrix would be.

• #### ( SET-FROM-ROTATION-X (MAT-TO-MUTATE MAT4) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat4 making it a matrix which would rotate a point around the x axis by the specified amount

• #### ( SET-FROM-ROTATION-Y (MAT-TO-MUTATE MAT4) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat4 making it a matrix which would rotate a point around the y axis by the specified amount

• #### ( SET-FROM-ROTATION-Z (MAT-TO-MUTATE MAT4) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat4 making it a matrix which would rotate a point around the z axis by the specified amount

• #### ( SET-FROM-ROWS (MAT-TO-MUTATE MAT4) (ROW-1 VEC4) (ROW-2 VEC4) (ROW-3 VEC4) (ROW-4 VEC4))

function

Destructively updates of the components of the given mat4 using the 4 vec4s provided to populate the rows

• #### ( SET-FROM-ROWS-V3 (MAT-TO-MUTATE MAT4) (ROW-1 VEC3) (ROW-2 VEC3) (ROW-3 VEC3))

function

Make a mat4 using the data in the 3 vec3 provided to populate the rows

The 4th row & column is filled as an identity matrix would be.

• #### ( SET-FROM-SCALE (MAT-TO-MUTATE MAT4) (SCALE-VEC3 VEC3))

function

Mutates the given mat4 to be a matrix which will scale by the amounts specified

• #### ( SET-FROM-TRANSLATION (MAT-TO-MUTATE MAT4) (VEC-A (SIMPLE-ARRAY SINGLE-FLOAT)))

function

Destructively updates of the components of the given mat4 making it a matrix which which will translate a point by the specified amount

• #### ( SET-ROTATION-FROM-AXIS-ANGLE (MAT-TO-MUTATE MAT4) (AXIS3 VEC3) (ANGLE SINGLE-FLOAT))

function

Destructively updates of the components of the given mat4 making it a matrix which will rotate a point about the axis specified by the angle provided

• #### ( SET-ROTATION-FROM-EULER (MAT-TO-MUTATE MAT4) (VEC3-A VEC3))

function

Destructively modifies the mat4 to be a rotation matrix whos rotation angles come from the vec3 provided.

• #### ( TRANSPOSE (MAT-TO-TRANSPOSE MAT4))

function

Mutates the given mat4 to be it's own transpose

• ### RTG-MATH.MATRICES(M)

• #### ( * MATRIX-A MAT-VEC-OR-SCALAR)

function

Takes any number of matrices (of the same kind) and multiplies them together returning a new matrix of the same kind.

• #### ( + &REST MATRICES)

function

Takes any number of matrices (of the same kind) and performs component-wise addition them together returning a new matrix of the same kind.

• #### ( - &REST MATRICES)

function

Takes any number of matrices (of the same kind) and performs component-wise negation of them returning a new matrix of the same kind.

• #### ( /= &REST MATRICES)

function

Returns either t if the matrices are equal. Otherwise it returns nil.

• #### ( 0P MATRIX)

function

Returns T if all the components of the matrix = 0

• #### ( 1+ MATRIX-A MATRIX-B)

function

Returns a new matrix which is equal to the given matrix with every component incremented by 1

• #### ( 1- MATRIX-A MATRIX-B)

function

Returns a new matrix which is equal to the given matrix with every component decremented by 1

• #### ( = &REST MATRICES)

function

Returns either t if the matrices are equal. Otherwise it returns nil.

• #### ( AFFINE-INVERSE MATRIX-A)

function

Returns a new matrix which is the inverse of the one given.

• #### ( DETERMINANT MATRIX-A)

function

Returns the determinant of the given matrix

function

function

• #### ( GET-COLUMN MATRIX-A COL-NUM)

function

Returns the specifed column of the matrix as vector

• #### ( GET-COLUMNS MATRIX-A)

function

Returns the columns of the matrix as a list of vectors

• #### ( GET-ROW MATRIX-A ROW-NUM)

function

Returns the specifed row of the matrix as vector

• #### ( GET-ROWS MATRIX-A)

function

Returns the rows of the matrix as a list of vectors

• #### ( INVERSE MATRIX-A)

function

Returns the inverse of the given matrix

• #### ( NEGATE MATRIX-A)

function

Returns a fresh matrix with all the components negated

function

{TODO}

• #### ( TRACE MATRIX-A)

function

Returns the trace of the given matrix as a vector

• #### ( TRANSPOSE MATRIX-A)

function

Returns the transpose of the given matrix

• #### ( UNITP MATRIX)

function

Returns T if the matrix is the unit matrix.

• ### RTG-MATH.QUATERNIONS(Q)

• #### ( * (QUAT-A QUATERNION) (QUAT-B QUATERNION))

function

Multiplies (and thus combines) the two quaternions given, returning a new quaternion

• #### ( *S (QUAT-A QUATERNION) (SCALAR SINGLE-FLOAT))

function

Component-wise multiplication of the quaternion by the scalar

• #### ( + &REST (QUATS QUATERNION))

function

Component-wise addition of any number of quaternions.

• #### ( - (QUAT QUATERNION) &REST (QUATS QUATERNION))

function

Takes any number of quaternion and performs component-wise subtraction on them returning a new quaternion

• #### ( /= (Q1 QUATERNION) (Q2 QUATERNION))

function

Component-wise comparison of two quaternions. Returns T if any components are not equal (by =)

• #### ( 0! )

function

Returns a new quaternion where every component is 0

• #### ( 0P (QUAT QUATERNION))

function

Returns T if all the components of the given quaternion are 0

• #### ( = (Q1 QUATERNION) (Q2 QUATERNION))

function

Returns T if the two quaternions given are component-wise equal (by cl:=)

• #### ( APPROX-SLERP (START-QUAT QUATERNION) (END-QUAT QUATERNION) (POS SINGLE-FLOAT))

function

A faster and less accurate version of slerp for quaternions

• #### ( CONJUGATE (QUAT QUATERNION))

function

Returns the conjugate of the given quaternion

• #### ( COPY (QUAT QUATERNION))

function

Returns a fresh quaternion which is = to the one given

• #### ( DOT (QUAT-A QUATERNION) (QUAT-B QUATERNION))

function

return the dot product of the quat-a and quat-b.

function

{TODO}

• #### ( FROM-AXIS-ANGLE (AXIS-VEC3 VEC3) (ANGLE SINGLE-FLOAT))

function

Returns a new quaternion which represents a rotation around the given axis by the given angle

• #### ( FROM-DIRECTION (UP3 VEC3) (DIR3 VEC3))

function

Creates a quaternion that would rotate the vector (v! 0 0 -1) to face in the given direction.

• #### ( FROM-FIXED-ANGLES (X-ROT SINGLE-FLOAT) (Y-ROT SINGLE-FLOAT) (Z-ROT SINGLE-FLOAT))

function

Creates a quaternion that represents a rotation around the given axies by the given angles

• #### ( FROM-FIXED-ANGLES-V3 (ANGLES VEC3))

function

Creates a quaternion that represents a rotation around the given axies by the angles given in the vec3

• #### ( FROM-MAT3 (MAT3 MAT3))

function

Creates quaternion that represents the same rotation the mat3 does.

• #### ( GET-AXIS-ANGLE (QUAT QUATERNION))

function

Gets one possible axis-angle pair that will generate this quaternion

Assumes that this is a normalized quaternion. It is critical that this is true as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( IDENTITY )

function

Returns a fresh identity quaternion

• #### ( IDENTITY-P (QUAT QUATERNION))

function

Returns T if the given quaternion is the identity quaternion

• #### ( INVERSE (QUAT QUATERNION))

function

Returns a new quaternion that is the inverse of the one given

• #### ( LERP (START-QUAT QUATERNION) (END-QUAT QUATERNION) (POS SINGLE-FLOAT))

function

Linearaly interpolate between two quaternions. Note that this will always take the shortest path.

• #### ( LOOK-AT (UP3 VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Creates a quaternion that would rotate the vector (v! 0 0 -1) to point in the direction from from3 to to3

• #### ( MAGNITUDE (QUAT QUATERNION))

function

Returns the magnitude of the quaternion

• #### ( MAKE (W SINGLE-FLOAT) (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT))

function

Make a quaternion from 4 single-floats

• #### ( NORM (QUAT QUATERNION))

function

Returns the 'norm' of the quaternion

Note: This is not the normalized verison of the quaternion, that is performed by the normalize function.

• #### ( NORMALIZE (QUAT QUATERNION))

function

Returns a fresh, normalized version of the given vector.

• #### ( POINT-AT (UP3 VEC3) (FROM3 VEC3) (TO3 VEC3))

function

Creates a quaternion that

• #### ( Q! (W SINGLE-FLOAT) (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT))

function

Make a quaternion from 4 single-floats

function

• #### ( ROTATE (VEC3 VEC3) (QUAT QUATERNION))

function

Rotates the given vec3 using the quaternion.

Assumes the quaternion is normalized.

• #### ( SLERP (START-QUAT QUATERNION) (END-QUAT QUATERNION) (POS SINGLE-FLOAT))

function

Spherically interpolate between two quaternions. Note that this will always take the shortest path.

• #### ( TO-DIRECTION (QUAT QUATERNION))

function

Returns a new vec3 is equal to (v! 0 0 -1) having been rotated by the given quaternion

• #### ( TO-DIRECTION-VEC4 (QUAT QUATERNION))

function

Returns a new vec4 is equal to (v! 0 0 -1 0) having been rotated by the given quaternion

• #### ( TO-MAT3 (QUAT QUATERNION))

function

Returns a new mat3 which represents the same rotation as the given quaternion

• #### ( TO-MAT4 (QUAT QUATERNION))

function

Returns a new mat4 which represents the same rotation as the given quaternion (and zero translation)

• #### ( UNITP (QUAT QUATERNION))

function

Returns T if this is a unit quaternion.

• #### ( W (QUAT QUATERNION))

function

Returns the w component of the quaternion

• #### ( X (QUAT QUATERNION))

function

Returns the x component of the quaternion

• #### ( Y (QUAT QUATERNION))

function

Returns the y component of the quaternion

• #### ( Z (QUAT QUATERNION))

function

Returns the z component of the quaternion

• ### RTG-MATH.QUATERNIONS.NON-CONSING(Q-N)

• #### ( * (QUAT-TO-MUTATE QUATERNION) (QUAT-B QUATERNION))

function

Destructively multiplies (and thus combines) the second quaternion into the first.

• #### ( + (ACCUM-QUAT QUATERNION) &REST (QUATERNIONS QUATERNION))

function

Destructively performs component-wise addition of the quaternions, the first quaternion is mutated.

• #### ( - (ACCUM-QUAT QUATERNION) &REST (QUATERNIONS QUATERNION))

function

Destructively performs component-wise substraction of the quaternions, the first quaternion is mutated.

• #### ( CONJUGATE (QUAT-TO-MUTATE QUATERNION))

function

Destructively replaces the given quaternion with it's conjugate

• #### ( FROM-AXIS-ANGLE (QUAT-TO-MUTATE QUATERNION) (AXIS-VEC3 VEC3) (ANGLE SINGLE-FLOAT))

function

Turns the given quaternion into one which represents a rotation around the given axis by the given angle

• #### ( FROM-FIXED-ANGLES (QUAT-TO-MUTATE QUATERNION) (X-ROT SINGLE-FLOAT) (Y-ROT SINGLE-FLOAT) (Z-ROT SINGLE-FLOAT))

function

Turns the given quaternion into one which represents a rotation around the given axies by the given angles.

• #### ( FROM-MAT3 (QUAT-TO-MUTATE QUATERNION) (MAT3 MAT3))

function

Destructively updates of the components of the given quaternion making it represent the rotation from the given mat3.

Assumes that this is a rotation matrix. It is critical that this is true (and elements are between -1f0 and 1f0) as otherwise you will at best get a runtime error, and most likely a silently incorrect result.

• #### ( NORMALIZE (QUAT-TO-MUTATE QUATERNION))

function

Destructively replaces the given quaternion with the normalized version of itself.

• #### ( ROTATE (VEC3-TO-MUTATE VEC3) (QUAT QUATERNION))

function

Destructively rotates the vec3 using the quaternion returning the mutated vec3.

ssumes quaternion is normalized.

• #### ( TO-MAT3 (MAT-TO-MUTATE MAT3) (QUAT QUATERNION))

function

Given a quaternion and a mat3 to mutate this function will mutate the mat3 such that it represents the same rotation as the quaternion does.

• #### ( TO-MAT4 (MAT-TO-MUTATE MAT4) (QUAT QUATERNION))

function

Given a quaternion and a mat4 to mutate this function will mutate the mat4 such that it represents the same rotation as the quaternion does.

• ### RTG-MATH.POLAR

• #### ( CARTESIAN->POLAR VEC2)

function

Takes a polar coord vector with the layout (θ r) and and converts it to a cartesian vec2

Notes: r - length of υ θ - angle between υ and y axis θ>0 means counter-clockwise rotation

• #### ( POLAR->CARTESIAN ANGLE-LENGTH-V2)

function
No docstring provided.
• ### RTG-MATH.SPHERICAL

• #### ( CARTESIAN->SPHERICAL VEC3)

function

Takes a cartesian vector3 and converts it to a spherical coord vector with the layout (θ φ ρ).

Notes: θ - angle between υ and x axis (rotating around z) φ - angle between υ and z axis ρ - distance from origin (lengh of υ)

• #### ( SPHERICAL->CARTESIAN SPHERICAL-COORD-V3)

function

Takes a spherical coord vector with the layout (θ φ ρ) and converts it to a cartesian vector3.

Notes: θ - angle between υ and x axis (rotating around z) φ - angle between υ and z axis ρ - distance from origin (lengh of υ)

• ### RTG-MATH.PROJECTION

• #### ( ORTHOGRAPHIC (FRAME-WIDTH SINGLE-FLOAT) (FRAME-HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT))

function

Creates a new orthographic projection matrix (mat4)

• #### ( ORTHOGRAPHIC-V2 (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT))

function

Creates a new orthographic projection matrix (mat4) with the frame size specified by a vec2

• #### ( PERSPECTIVE (WIDTH SINGLE-FLOAT) (HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Creates a perspective matrix (mat4) with the field of view being specified in degrees.

The fact that the primary function form takes degress is unusual in rtg-math. We keep it this way for backwards compatibility. For the version specified in radians see perspective-radian-fov

• #### ( PERSPECTIVE-RADIAN-FOV (WIDTH SINGLE-FLOAT) (HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV SINGLE-FLOAT))

function

Creates a perspective matrix (mat4).

• #### ( PERSPECTIVE-V2 (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Creates a perspective matrix (mat4) with the frame size specified using a vec2 and the field of view being specified in degrees.

This variant of perspective that is provided as some libraries will provide the framesize as a vec2 so it felt right to support that rather that force unpacking.

The fact that the primary function form takes degress is unusual in rtg-math. We keep it this way for backwards compatibility. For the version specified in radians see perspective-radian-fov

• #### ( PERSPECTIVE-V2-RADIAN-FOV (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Creates a perspective matrix (mat4) with the frame size specified using a vec2

This variant of perspective that is provided as some libraries will provide the framesize as a vec2 so it felt right to support that rather that force unpacking.

• ### RTG-MATH.PROJECTION.NON-CONSING

• #### ( ORTHOGRAPHIC (MAT4-TO-MUTATE MAT4) (FRAME-WIDTH SINGLE-FLOAT) (FRAME-HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT))

function

Creates a mat4 and mutates it to be an orthographic projection matrix

• #### ( ORTHOGRAPHIC-V2 (MAT4-TO-MUTATE MAT4) (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT))

function

Creates a mat4 and mutates it to be an orthographic projection matrix (with the frame size specified by a vec2)

• #### ( PERSPECTIVE (MAT-TO-MUTATE MAT4) (WIDTH SINGLE-FLOAT) (HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Takes a mat4 and mutates it to be a perspective matrix with the field of view being specified in degrees.

The fact that the primary function form takes degress is unusual in rtg-math. We keep it this way for backwards compatibility. For the version specified in radians see perspective-radian-fov

• #### ( PERSPECTIVE-RADIAN-FOV (MAT-TO-MUTATE MAT4) (WIDTH SINGLE-FLOAT) (HEIGHT SINGLE-FLOAT) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV SINGLE-FLOAT))

function

Takes a mat4 and mutates it to be a perspective matrix

• #### ( PERSPECTIVE-V2 (MAT-TO-MUTATE MAT4) (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Takes a mat4 and mutates it to be a perspective matrix with the frame size specified using a vec2 and the field of view being specified in degrees.

This variant of perspective that is provided as some libraries will provide the framesize as a vec2 so it felt right to support that rather that force unpacking.

The fact that the primary function form takes degress is unusual in rtg-math. We keep it this way for backwards compatibility. For the version specified in radians see perspective-radian-fov

• #### ( PERSPECTIVE-V2-RADIAN-FOV (MAT-TO-MUTATE MAT4) (FRAME-SIZE-V2 VEC2) (NEAR SINGLE-FLOAT) (FAR SINGLE-FLOAT) (FOV-DEGREES SINGLE-FLOAT))

function

Takes a mat4 and mutates it to be a perspective matrix with the frame size specified using a vec2

This variant of perspective that is provided as some libraries will provide the framesize as a vec2 so it felt right to support that rather that force unpacking.

• ### RTG-MATH.REGION.LINE3(LINE3)

• #### LINE3

class
No docstring provided.
• #### ( CLOSEST-LINE-POINTS (LINE3-A LINE3) (LINE3-B LINE3))

function
No docstring provided.
• #### ( CLOSEST-POINT (LINE3 LINE3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DIRECTION (LINE3 LINE3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-LINE3 (LINE3-A LINE3) (LINE3-B LINE3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-POINT (LINE3 LINE3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DISTANCE-TO-LINE3 (LINE3-A LINE3) (LINE3-B LINE3))

function
No docstring provided.
• #### ( DISTANCE-TO-POINT (LINE3 LINE3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( MAKE (ORIGIN-V3 VEC3) (DIRECTION-V3 VEC3))

function
No docstring provided.
• #### ( ORIGIN (LINE3 LINE3))

function
No docstring provided.
• #### ( TRANSFORM-M3 (MATRIX3 MAT3) (LINE3 LINE3))

function
No docstring provided.
• #### ( TRANSFORM-Q (QUAT QUATERNION) (LINE3 LINE3))

function
No docstring provided.
• ### RTG-MATH.REGION.RAY3(RAY3)

• #### RAY3

class
No docstring provided.
• #### ( /= (RAY3-A RAY3) (RAY3-B RAY3))

function
No docstring provided.
• #### ( = (RAY3-A RAY3) (RAY3-B RAY3))

function
No docstring provided.
• #### ( CLOSEST-POINT (RAY3 RAY3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( CLOSEST-RAY-POINTS (RAY3-A RAY3) (RAY3-B RAY3))

function
No docstring provided.
• #### ( DIRECTION (RAY3 RAY3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-LINE3 (RAY3 RAY3) (LINE3 LINE3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-POINT (RAY3 RAY3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-RAY3 (RAY3-A RAY3) (RAY3-B RAY3))

function
No docstring provided.
• #### ( DISTANCE-TO-LINE3 (RAY3 RAY3) (LINE3 LINE3))

function
No docstring provided.
• #### ( DISTANCE-TO-POINT (RAY3 RAY3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DISTANCE-TO-RAY3 (RAY3-A RAY3) (RAY3-B RAY3))

function
No docstring provided.
• #### ( MAKE (ORIGIN-V3 VEC3) (DIRECTION-V3 VEC3))

function
No docstring provided.
• #### ( ORIGIN (RAY3 RAY3))

function
No docstring provided.
• #### ( TRANSFORM-M3 (MATRIX3 MAT3) (RAY3 RAY3))

function
No docstring provided.
• #### ( TRANSFORM-Q (QUAT QUATERNION) (RAY3 RAY3))

function
No docstring provided.
• ### RTG-MATH.REGION.LINE-SEGMENT3(LINE-SEG3)

• #### ( /= (LINE-SEG3-A LINE-SEGMENT3) (LINE-SEG3-B LINE-SEGMENT3))

function
No docstring provided.
• #### ( = (LINE-SEG3-A LINE-SEGMENT3) (LINE-SEG3-B LINE-SEGMENT3))

function
No docstring provided.
• #### ( CLOSEST-LINE-POINTS (LINE-SEG3 LINE-SEGMENT3) (LINE3 LINE3))

function
No docstring provided.
• #### ( CLOSEST-LINE-SEGMENT-POINTS (LINE-SEG-A LINE-SEGMENT3) (LINE-SEG-B LINE-SEGMENT3))

function
No docstring provided.
• #### ( CLOSEST-POINT (LINE-SEG3 LINE-SEGMENT3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( CLOSEST-RAY-POINTS (LINE-SEG-A LINE-SEGMENT3) (RAY3 RAY3))

function
No docstring provided.
• #### ( DIRECTION (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-LINE-SEG3 (LINE-SEG-A LINE-SEGMENT3) (LINE-SEG-B LINE-SEGMENT3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-LINE3 (LINE-SEG3 LINE-SEGMENT3) (LINE3 LINE3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-POINT (LINE-SEG3 LINE-SEGMENT3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DISTANCE-SQUARED-TO-RAY3 (LINE-SEG3 LINE-SEGMENT3) (RAY3 RAY3))

function
No docstring provided.
• #### ( DISTANCE-TO-LINE-SEG3 (LINE-SEG-A LINE-SEGMENT3) (LINE-SEG-B LINE-SEGMENT3))

function
No docstring provided.
• #### ( DISTANCE-TO-LINE3 (LINE-SEG3 LINE-SEGMENT3) (LINE3 LINE3))

function
No docstring provided.
• #### ( DISTANCE-TO-POINT (LINE-SEG3 LINE-SEGMENT3) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( DISTANCE-TO-RAY3 (LINE-SEG3 LINE-SEGMENT3) (RAY3 RAY3))

function
No docstring provided.
• #### ( END-POINT0 (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( END-POINT1 (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( LENGTH (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( LENGTH-SQUARED (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( MAKE (END-POINT0 VEC3) (END-POINT1 VEC3))

function
No docstring provided.
• #### ( MAKE-FROM-POINT-OFFSET (POINT-V3 VEC3) (OFFSET-V3 VEC3))

function
No docstring provided.
• #### ( TRANSFORM-M3 (MATRIX3 MAT3) (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( TRANSFORM-Q (QUAT QUATERNION) (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• ### RTG-MATH.REGION.AXIS-ALIGNED-BOX.NON-CONSING(AAB-N)

• #### ( MERGE-POINT (AAB AXIS-ALIGNED-BOX) (POINT-V3 VEC3))

function
No docstring provided.
• ### RTG-MATH.REGION.AXIS-ALIGNED-BOX(AAB)

• #### AXIS-ALIGNED-BOX

class
No docstring provided.
• #### ( /= (AAB-0 AXIS-ALIGNED-BOX) (AAB-1 AXIS-ALIGNED-BOX))

function
No docstring provided.
• #### ( = (AAB-0 AXIS-ALIGNED-BOX) (AAB-1 AXIS-ALIGNED-BOX))

function
No docstring provided.
• #### ( ADD-POINT (AAB AXIS-ALIGNED-BOX) (POINT-V3 VEC3))

function
No docstring provided.
• #### ( FROM-AABS &REST (AABS AXIS-ALIGNED-BOX))

function
No docstring provided.
• #### ( FROM-POINTS (LIST-OF-VEC3 LIST))

function
No docstring provided.
• #### ( INTERSECTS-P (AAB-0 AXIS-ALIGNED-BOX) (AAB-1 AXIS-ALIGNED-BOX))

function
No docstring provided.
• #### ( INTERSECTS-WITH-LINE-SEGMENT-P (AAB AXIS-ALIGNED-BOX) (LINE-SEG3 LINE-SEGMENT3))

function
No docstring provided.
• #### ( INTERSECTS-WITH-LINE3-P (AAB AXIS-ALIGNED-BOX) (LINE3 LINE3))

function
No docstring provided.
• #### ( INTERSECTS-WITH-RAY3-P (AAB AXIS-ALIGNED-BOX) (RAY3 RAY3))

function
No docstring provided.
• #### ( MAKE (MINIMA VEC3) (MAXIMA VEC3))

function
No docstring provided.
• #### ( MAXIMA (AAB AXIS-ALIGNED-BOX))

function
No docstring provided.
• #### ( MINIMA (AAB AXIS-ALIGNED-BOX))

function
No docstring provided.
• ### RTG-MATH.REGION(REGIONS)

• #### ( CLOSEST-POINT REG-A VEC3)

generic
No docstring provided.
• #### ( CLOSEST-POINTS REG-A REG-B)

generic
No docstring provided.
• #### ( DISTANCE REG-A REG-B)

generic
No docstring provided.
• #### ( DISTANCE-SQUARED REG-A REG-B)

generic
No docstring provided.
• #### ( INTERSECTS-P REG-A REG-B)

generic
No docstring provided.
• ### RTG-MATH

• #### +INV-PI+

constant

(/ 1 pi) as a single-float. This is the older naming, it is now prefered to use inv-pi-f

constant

The number of degrees in 1 radian as a single-float

• #### +PI+

constant

pi as a single-float. This is the older naming, it is now prefered to use pi-f

• #### 0.5PI

constant

(/ pi 2) as a double-float

• #### 0.5PI-F

constant

(/ pi 2) as a single-float

• #### 2PI-F

constant

(* PI 2) as a single-float

constant

• #### INV-PI-F

constant

(/ 1 pi) as asingle-float`

• #### ( CLAMP (MIN SINGLE-FLOAT) (MAX SINGLE-FLOAT) (VAL-F SINGLE-FLOAT))

function

Force a single-float to be constrained to the given range.

Equivalent to (min (max val-f min) max)

function

Converts a quantity, specified in radians into degrees.

function

Converts a quantity, specified in radians as a single-float into degrees.

• #### ( INV-SQRT (X (SINGLE-FLOAT 0.0 3.4028235e38)))

function

Calculates the inverse square root of a number

• #### ( LERP (START SINGLE-FLOAT) (END SINGLE-FLOAT) (AMOUNT SINGLE-FLOAT))

function

Performs a linear interpolation between 'start' and 'end' by the given amount

• #### ( M! &REST COMPONENTS)

function

Creates a new mat2, mat3 or mat4 based on the number of components provided.

• #### ( MIX (START SINGLE-FLOAT) (END SINGLE-FLOAT) (AMOUNT SINGLE-FLOAT))

function

Performs a linear interpolation between 'start' and 'end' by the given amount

• #### ( Q! (W SINGLE-FLOAT) (X SINGLE-FLOAT) (Y SINGLE-FLOAT) (Z SINGLE-FLOAT))

function

Make a quaternion from 4 single-floats

function

Converts a quantity, specified in degrees into radians.

function

Converts a quantity, specified in degrees as a single-float into radians.

• #### ( SATURATE (VAL-F SINGLE-FLOAT))

function

clamps the given single-float between 0.0 and 1.0

• #### ( SMOOTHSTEP (A SINGLE-FLOAT) (B SINGLE-FLOAT) (X SINGLE-FLOAT))

function

Performs smooth Hermite interpolation between 0 and 1 when 'a' < 'x' < 'b'

function

{TODO}

• #### ( S~ VEC PATTERN)

function

Shorthand for swizzle

s~ allows you to compose a new vector out of an existing one by picking it's components.

Given a vec3 called a = (v! 1 2 3)

• (s~ a :xy) → (v! 1 2)
• (s~ a :xx) → (v! 1 1)
• (s~ a :yx) → (v! 2 1)
• (s~ a :yyyy) → (v! 2 2 2 2)
• (s~ a :zzyy) → (v! 3 3 2 2)
• #### ( V! &REST COMPONENTS)

function

Create a vec2, vec3 or vec4. The kind of vector returned by this function depends on what is passed as the arguments.

It can take any number of the following..

• floats
• integers
• vec2
• vec3
• vec4

so long as the total number of components is 2, 3 or 4. So any of the following examples are valid:

• (v! 1 2 3 4)
• (v! 1.0 2 3.0 4)
• (v! 1 (v! 2 3) 4)
• (v! (v! 1 2) (v! 3 4))
• (v! (v! 1 2 3) 4.0)
• #### ( V!BOOL &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 booleans out of booleans or other boolean vectors

• #### ( V!BYTE &REST COMPONENTS)

function

a vector of 2, 3 or 4 bytes out of bytes or other byte vectors

• #### ( V!DOUBLE &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 doubles out of doubles or other double vectors

• #### ( V!INT &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 ints out of ints or other int vectors

• #### ( V!INT8 &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 int8s out of int8s or other int8 vectors

• #### ( V!UBYTE &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 ubytes out of ubytes or other ubyte vectors

• #### ( V!UINT &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 uints out of uints or other uint vectors

• #### ( V!UINT8 &REST COMPONENTS)

function

Create a vector of 2, 3 or 4 uint8s out of uint8s or other uint8 vectors

• #### ( V2! X &OPTIONAL Y)

function

Create vec2 from 1 or 2 floats or ints

• #### ( V2!BYTE X &OPTIONAL Y)

function

Create vector of two bytes from 1 or 2 bytes

• #### ( V2!DOUBLE X &OPTIONAL Y)

function

Create vector of two doubles from 1 or 2 doubles

• #### ( V2!INT X &OPTIONAL Y)

function

Create vector of two ints from 1 or 2 ints

• #### ( V2!INT8 X &OPTIONAL Y)

function

Create vector of two int8s from 1 or 2 int8s

• #### ( V2!SHORT X &OPTIONAL Y)

function

Create vector of two shorts from 1 or 2 shorts

• #### ( V2!UBYTE X &OPTIONAL Y)

function

Create vector of two ubytes from 1 or 2 ubytes

• #### ( V2!UINT X &OPTIONAL Y)

function

Create vector of two uints from 1 or 2 uints

• #### ( V2!UINT8 X &OPTIONAL Y)

function

Create vector of two uint8s from 1 or 2 uint8s

• #### ( V2!USHORT X &OPTIONAL Y)

function

Create vector of two ushorts from 1 or 2 ushorts

• #### ( V3! X &OPTIONAL Y Z)

function

Create a vec3 from 1, 2 or 3 floats or ints.

• #### ( V3!BYTE X &OPTIONAL Y Z)

function

Creates a vector of 3 bytes from 1, 2 or 3 bytes

• #### ( V3!DOUBLE X &OPTIONAL Y Z)

function

Creates a vector of 3 doubles from 1, 2 or 3 doubles

• #### ( V3!INT X &OPTIONAL Y Z)

function

Creates a vector of 3 ints from 1, 2 or 3 ints

• #### ( V3!INT8 X &OPTIONAL Y Z)

function

Creates a vector of 3 int8s from 1, 2 or 3 int8s

• #### ( V3!SHORT X &OPTIONAL Y Z)

function

Creates a vector of 3 shorts from 1, 2 or 3 shorts

• #### ( V3!UBYTE X &OPTIONAL Y Z)

function

Creates a vector of 3 ubytes from 1, 2 or 3 ubytes

• #### ( V3!UINT X &OPTIONAL Y Z)

function

Creates a vector of 3 uints from 1, 2 or 3 uints

• #### ( V3!UINT8 X &OPTIONAL Y Z)

function

Creates a vector of 3 uint8s from 1, 2 or 3 uint8s

• #### ( V3!USHORT X &OPTIONAL Y Z)

function

Creates a vector of 3 ushorts from 1, 2 or 3 ushorts

• #### ( V4! X &OPTIONAL Y Z W)

function

Create a vec4 from 1, 2, 3 or 4 floats or ints

• #### ( V4!BYTE X &OPTIONAL Y Z W)

function

Creates a vector of 4 bytes from 1, 2, 3 or 4 bytes

• #### ( V4!DOUBLE X &OPTIONAL Y Z W)

function

Creates a vector of 4 doubles from 1, 2, 3 or 4 doubles

• #### ( V4!INT X &OPTIONAL Y Z W)

function

Creates a vector of 4 ints from 1, 2, 3 or 4 ints

• #### ( V4!INT8 X &OPTIONAL Y Z W)

function

Creates a vector of 4 int8s from 1, 2, 3 or 4 int8s

• #### ( V4!SHORT X &OPTIONAL Y Z W)

function

Creates a vector of 4 shorts from 1, 2, 3 or 4 shorts

• #### ( V4!UBYTE X &OPTIONAL Y Z W)

function

Creates a vector of 4 ubytes from 1, 2, 3 or 4 ubytes

• #### ( V4!UINT X &OPTIONAL Y Z W)

function

Creates a vector of 4 uints from 1, 2, 3 or 4 uints

• #### ( V4!UINT8 X &OPTIONAL Y Z W)

function

Creates a vector of 4 uint8s from 1, 2, 3 or 4 uint8s

• #### ( V4!USHORT X &OPTIONAL Y Z W)

function

Creates a vector of 4 ushorts from 1, 2, 3 or 4 ushorts

• #### ( W VEC)

function

Returns the w component of the vector

• #### ( X VEC)

function

Returns the x component of the vector

• #### ( Y VEC)

function

Returns the y component of the vector

• #### ( Z VEC)

function

Returns the z component of the vector