1.17 <GrapheneVec4>

Structure: <GrapheneVec4>

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

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

Procedures

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

Adds each component of the two given vectors.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the resulting vector

Procedure: vec4:alloc ⇒ %return

Allocates a new <GrapheneVec4> structure.

The contents of the returned structure are undefined.

Use vec4:init to initialize the vector.

%return

Returned: a <GrapheneVec4>.

the newly allocated <GrapheneVec4> structure. Use vec4:free to free the resources allocated by this function.

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the resulting vector

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

Computes the dot product of the two given vectors.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the value of the dot product

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

Checks whether the two given <GrapheneVec4> are equal.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

v2

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a boolean.

true if the two vectors are equal, and false otherwise

Method: vec4:free self
Method: free self

Frees the resources allocated by self

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

Method: vec4:get-w self ⇒ %return
Method: get-w self ⇒ %return

Retrieves the value of the fourth component of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the value of the fourth component

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

Retrieves the value of the first component of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the value of the first component

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

Creates a <GrapheneVec2> that contains the first two components of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for a <GrapheneVec2>

Method: vec4:get-xyz! self res ⇒ res
Method: get-xyz! self res ⇒ res

Creates a <GrapheneVec3> that contains the first three components of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for a graphene_vec3_t

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

Retrieves the value of the second component of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the value of the second component

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

Retrieves the value of the third component of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the value of the third component

Method: vec4:init self x y z w ⇒ %return
Method: init self x y z w ⇒ %return

Initializes a <GrapheneVec4> using the given values.

This function can be called multiple times.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

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

w

Passed: a real number.

the W field of the vector

%return

Returned: a <GrapheneVec4>.

a pointer to the initialized vector

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

Initializes a <GrapheneVec4> with the values inside the given array.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

src

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

an array of four floating point values

%return

Returned: a <GrapheneVec4>.

the initialized vector

Method: vec4:init-from-vec2 self src z w ⇒ %return
Method: init-from-vec2 self src z w ⇒ %return

Initializes a <GrapheneVec4> using the components of a <GrapheneVec2> and the values of z and w.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

src

Passed: a <GrapheneVec2>.

a <GrapheneVec2>

z

Passed: a real number.

the value for the third component of self

w

Passed: a real number.

the value for the fourth component of self

%return

Returned: a <GrapheneVec4>.

the initialized vector

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

Initializes a <GrapheneVec4> using the components of a <GrapheneVec3> and the value of w.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

src

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

w

Passed: a real number.

the value for the fourth component of self

%return

Returned: a <GrapheneVec4>.

the initialized vector

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

Initializes a <GrapheneVec4> using the components of another <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

src

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a <GrapheneVec4>.

the initialized vector

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

v2

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

factor

Passed: a real number.

the interpolation factor

res

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

the interpolated vector

Method: vec4:length self ⇒ %return
Method: length self ⇒ %return

Computes the length of the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a real number.

the length of the vector

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the result vector

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the result vector

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

Multiplies each component of the two given vectors.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the resulting vector

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

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

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

v2

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

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: vec4:negate! self res ⇒ res
Method: negate! self res ⇒ res

Negates the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the result vector

Method: vec4:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Normalizes the given <GrapheneVec4>.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the normalized vector

Procedure: vec4:one ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with all its components set to 1.

%return

Returned: a <GrapheneVec4>.

a constant vector

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

factor

Passed: a real number.

the scalar factor

res

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

return location for the result vector

Method: vec4: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 <GrapheneVec4>.

a <GrapheneVec4>

b

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

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

return location for the resulting vector

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

Stores the components of the given <GrapheneVec4> into an array of floating point values.

self

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

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: vec4:w-axis ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with its components set to (0, 0, 0, 1).

%return

Returned: a <GrapheneVec4>.

a constant vector

Procedure: vec4:x-axis ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with its components set to (1, 0, 0, 0).

%return

Returned: a <GrapheneVec4>.

a constant vector

Procedure: vec4:y-axis ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with its components set to (0, 1, 0, 0).

%return

Returned: a <GrapheneVec4>.

a constant vector

Procedure: vec4:z-axis ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with its components set to (0, 0, 1, 0).

%return

Returned: a <GrapheneVec4>.

a constant vector

Procedure: vec4:zero ⇒ %return

Retrieves a pointer to a <GrapheneVec4> with all its components set to 0.

%return

Returned: a <GrapheneVec4>.

a constant vector