1.16 <GrapheneVec3>

Structure: <GrapheneVec3>

A structure capable of holding a vector with three dimensions: x, y, and z.

The contents of the <GrapheneVec3> structure are private and should never be accessed directly.

Procedures

Method: vec3:add! self b res ⇒ res
Method: add! self b res ⇒ res

Adds each component of the two given vectors.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the resulting vector

Procedure: vec3:alloc ⇒ %return

Allocates a new <GrapheneVec3> structure.

The contents of the returned structure are undefined.

Use vec3:init to initialize the vector.

%return

Returned: a <GrapheneVec3>.

the newly allocated <GrapheneVec3> structure. Use vec3:free to free the resources allocated by this function.

Method: vec3:cross! self b res ⇒ res
Method: cross! self b res ⇒ res

Computes the cross product of the two given vectors.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the resulting vector

Method: vec3:divide! self b res ⇒ res
Method: divide! self b res ⇒ res

Divides each component of the first operand self by the corresponding component of the second operand b, and places the results into the vector res.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the resulting vector

Method: vec3:dot self b ⇒ %return
Method: dot self b ⇒ %return

Computes the dot product of the two given vectors.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a real number.

the value of the dot product

Method: vec3:equal? self v2 ⇒ %return
Method: equal? self v2 ⇒ %return

Checks whether the two given <GrapheneVec3> are equal.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

v2

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a boolean.

true if the two vectors are equal, and false otherwise

Method: vec3:free self
Method: free self

Frees the resources allocated by self

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

Method: vec3:get-x self ⇒ %return
Method: get-x self ⇒ %return

Retrieves the first component of the given vector self.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a real number.

the value of the first component of the vector

Method: vec3:get-xy! self res ⇒ res
Method: get-xy! self res ⇒ res

Creates a <GrapheneVec2> that contains the first and second components of the given <GrapheneVec3>.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec2>.

return location for a <GrapheneVec2>

Method: vec3:get-xy0! self res ⇒ res
Method: get-xy0! self res ⇒ res

Creates a <GrapheneVec3> that contains the first two components of the given <GrapheneVec3>, and the third component set to 0.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for a <GrapheneVec3>

Method: vec3:get-xyz0! self res ⇒ res
Method: get-xyz0! self res ⇒ res

Converts a <GrapheneVec3> in a <GrapheneVec4> using 0.0 as the value for the fourth component of the resulting vector.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for the vector

Method: vec3:get-xyz1! self res ⇒ res
Method: get-xyz1! self res ⇒ res

Converts a <GrapheneVec3> in a <GrapheneVec4> using 1.0 as the value for the fourth component of the resulting vector.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for the vector

Method: vec3:get-xyzw! self w res ⇒ res
Method: get-xyzw! self w res ⇒ res

Converts a <GrapheneVec3> in a <GrapheneVec4> using w as the value of the fourth component of the resulting vector.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

w

Passed: a real number.

the value of the W component

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for the vector

Method: vec3:get-y self ⇒ %return
Method: get-y self ⇒ %return

Retrieves the second component of the given vector self.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a real number.

the value of the second component of the vector

Method: vec3:get-z self ⇒ %return
Method: get-z self ⇒ %return

Retrieves the third component of the given vector self.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a real number.

the value of the third component of the vector

Method: vec3:init self x y z ⇒ %return
Method: init self x y z ⇒ %return

Initializes a <GrapheneVec3> using the given values.

This function can be called multiple times.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

x

Passed: a real number.

the X field of the vector

y

Passed: a real number.

the Y field of the vector

z

Passed: a real number.

the Z field of the vector

%return

Returned: a <GrapheneVec3>.

a pointer to the initialized vector

Method: vec3:init-from-float self src ⇒ %return
Method: init-from-float self src ⇒ %return

Initializes a <GrapheneVec3> with the values from an array.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

src

Passed: a f32vector, or a list or vector, each a real number.

an array of 3 floating point values

%return

Returned: a <GrapheneVec3>.

the initialized vector

Method: vec3:init-from-vec3 self src ⇒ %return
Method: init-from-vec3 self src ⇒ %return

Initializes a <GrapheneVec3> with the values of another <GrapheneVec3>.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

src

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a <GrapheneVec3>.

the initialized vector

Method: vec3:interpolate! self v2 factor res ⇒ res
Method: interpolate! self v2 factor res ⇒ res

Linearly interpolates self and v2 using the given factor.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

v2

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

factor

Passed: a real number.

the interpolation factor

res

Passed, filled in, and returned: a <GrapheneVec3>.

the interpolated vector

Method: vec3:length self ⇒ %return
Method: length self ⇒ %return

Retrieves the length of the given vector self.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a real number.

the value of the length of the vector

Method: vec3:max! self b res ⇒ res
Method: max! self b res ⇒ res

Compares each component of the two given vectors and creates a vector that contains the maximum values.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the result vector

Method: vec3:min! self b res ⇒ res
Method: min! self b res ⇒ res

Compares each component of the two given vectors and creates a vector that contains the minimum values.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the result vector

Method: vec3:multiply! self b res ⇒ res
Method: multiply! self b res ⇒ res

Multiplies each component of the two given vectors.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the resulting vector

Method: vec3:near? self v2 epsilon ⇒ %return
Method: near? self v2 epsilon ⇒ %return

Compares the two given <GrapheneVec3> vectors and checks whether their values are within the given epsilon.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

v2

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

epsilon

Passed: a real number.

the threshold between the two vectors

%return

Returned: a boolean.

true if the two vectors are near each other

Method: vec3:negate! self res ⇒ res
Method: negate! self res ⇒ res

Negates the given <GrapheneVec3>.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the result vector

Method: vec3:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Normalizes the given <GrapheneVec3>.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the normalized vector

Procedure: vec3:one ⇒ %return

Provides a constant pointer to a vector with three components, all sets to 1.

%return

Returned: a <GrapheneVec3>.

a constant vector

Method: vec3:scale! self factor res ⇒ res
Method: scale! self factor res ⇒ res

Multiplies all components of the given vector with the given scalar factor.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

factor

Passed: a real number.

the scalar factor

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the result vector

Method: vec3:subtract! self b res ⇒ res
Method: subtract! self b res ⇒ res

Subtracts from each component of the first operand self the corresponding component of the second operand b and places each result into the components of res.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

b

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the resulting vector

Method: vec3:to-float! self dest ⇒ dest
Method: to-float! self dest ⇒ dest

Copies the components of a <GrapheneVec3> into the given array.

self

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

dest

Passed: a f32vector, or a list or vector, each a real number. It is filled in, and returned: a f32vector.

return location for an array of floating point values

Procedure: vec3:x-axis ⇒ %return

Provides a constant pointer to a vector with three components with values set to (1, 0, 0).

%return

Returned: a <GrapheneVec3>.

a constant vector

Procedure: vec3:y-axis ⇒ %return

Provides a constant pointer to a vector with three components with values set to (0, 1, 0).

%return

Returned: a <GrapheneVec3>.

a constant vector

Procedure: vec3:z-axis ⇒ %return

Provides a constant pointer to a vector with three components with values set to (0, 0, 1).

%return

Returned: a <GrapheneVec3>.

a constant vector

Procedure: vec3:zero ⇒ %return

Provides a constant pointer to a vector with three components, all sets to 0.

%return

Returned: a <GrapheneVec3>.

a constant vector