1.6 <GraphenePoint3D>

Structure: <GraphenePoint3D>

A point with three components: X, Y, and Z.

Fields

x

the X coordinate

y

the Y coordinate

z

the Z coordinate

Procedures

Procedure: point3d:alloc ⇒ %return

Allocates a <GraphenePoint3D> structure.

%return

Returned: a <GraphenePoint3D>.

the newly allocated structure. Use point3d:free to free the resources allocated by this function.

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

Computes the cross product of the two given <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

res

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

return location for the cross product

Method: point3d:distance! self b delta ⇒ %return delta
Method: distance! self b delta ⇒ %return delta

Computes the distance between the two given <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

delta

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

return location for the distance components on the X, Y, and Z axis

%return

Returned: a real number.

the distance between two points

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

Computes the dot product of the two given <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a real number.

the value of the dot product

Method: point3d:equal? self b ⇒ %return
Method: equal? self b ⇒ %return

Checks whether two given points are equal.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a boolean.

true if the points are equal

Method: point3d:free self
Method: free self

Frees the resources allocated via point3d:alloc.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

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

Initializes a <GraphenePoint3D> with the given coordinates.

self

Passed: a <GraphenePoint3D>.

the <GraphenePoint3D> to initialize

x

Passed: a real number.

the X coordinate of the point

y

Passed: a real number.

the Y coordinate of the point

z

Passed: a real number.

the Z coordinate of the point

%return

Returned: a <GraphenePoint3D>.

the initialized <GraphenePoint3D>

Method: point3d:init-from-point self src ⇒ %return
Method: init-from-point self src ⇒ %return

Initializes a <GraphenePoint3D> using the coordinates of another <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

src

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a <GraphenePoint3D>.

the initialized point

Method: point3d:init-from-vec3 self v ⇒ %return
Method: init-from-vec3 self v ⇒ %return

Initializes a <GraphenePoint3D> using the components of a <GrapheneVec3>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

v

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

%return

Returned: a <GraphenePoint3D>.

the initialized <GraphenePoint3D>

Method: point3d:interpolate! self b factor res ⇒ res
Method: interpolate! self b factor res ⇒ res

Linearly interpolates each component of self and b using the provided factor, and places the result in res.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

factor

Passed: a real number.

the interpolation factor

res

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

the return location for the interpolated <GraphenePoint3D>

Method: point3d:length self ⇒ %return
Method: length self ⇒ %return

Computes the length of the vector represented by the coordinates of the given <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a real number.

the length of the vector represented by the point

Method: point3d:near? self b epsilon ⇒ %return
Method: near? self b epsilon ⇒ %return

Checks whether the two points are near each other, within an epsilon factor.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

epsilon

Passed: a real number.

fuzzyness factor

%return

Returned: a boolean.

true if the points are near each other

Method: point3d:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Computes the normalization of the vector represented by the coordinates of the given <GraphenePoint3D>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

res

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

return location for the normalized <GraphenePoint3D>

Method: point3d:normalize-viewport! self viewport z-near z-far res ⇒ res
Method: normalize-viewport! self viewport z-near z-far res ⇒ res

Normalizes the coordinates of a <GraphenePoint3D> using the given viewport and clipping planes.

The coordinates of the resulting <GraphenePoint3D> will be in the [ -1, 1 ] range.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

viewport

Passed: a <GrapheneRect>.

a <GrapheneRect> representing a viewport

z-near

Passed: a real number.

the coordinate of the near clipping plane, or 0 for the default near clipping plane

z-far

Passed: a real number.

the coordinate of the far clipping plane, or 1 for the default far clipping plane

res

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

the return location for the normalized <GraphenePoint3D>

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

Scales the coordinates of the given <GraphenePoint3D> by the given factor.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

factor

Passed: a real number.

the scaling factor

res

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

return location for the scaled point

Method: point3d:to-vec3! self v ⇒ v
Method: to-vec3! self v ⇒ v

Stores the coordinates of a <GraphenePoint3D> into a <GrapheneVec3>.

self

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

v

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

return location for a <GrapheneVec3>

Procedure: point3d:zero ⇒ %return

Retrieves a constant point with all three coordinates set to 0.

%return

Returned: a <GraphenePoint3D>.

a zero point