1.5 <GraphenePlane>

Structure: <GraphenePlane>

A 2D plane that extends infinitely in a 3D volume.

The contents of the <GraphenePlane> are private, and should not be modified directly.

Procedures

Procedure: plane:alloc ⇒ %return

Allocates a new <GraphenePlane> structure.

The contents of the returned structure are undefined.

%return

Returned: a <GraphenePlane>.

the newly allocated <GraphenePlane>. Use plane:free to free the resources allocated by this function

Method: plane:distance self point ⇒ %return
Method: distance self point ⇒ %return

Computes the distance of point from a <GraphenePlane>.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

point

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a real number.

the distance of the given <GraphenePoint3D> from the plane

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

Checks whether the two given <GraphenePlane> are equal.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

b

Passed: a <GraphenePlane>.

a <GraphenePlane>

%return

Returned: a boolean.

true if the given planes are equal

Method: plane:free self
Method: free self

Frees the resources allocated by plane:alloc.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

Method: plane:get-constant self ⇒ %return
Method: get-constant self ⇒ %return

Retrieves the distance along the normal vector of the given <GraphenePlane> from the origin.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

%return

Returned: a real number.

the constant value of the plane

Method: plane:get-normal! self normal ⇒ normal
Method: get-normal! self normal ⇒ normal

Retrieves the normal vector pointing towards the origin of the given <GraphenePlane>.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

normal

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

return location for the normal vector

Method: plane:init self normal constant ⇒ %return
Method: init self normal constant ⇒ %return

Initializes the given <GraphenePlane> using the given normal vector and constant values.

self

Passed: a <GraphenePlane>.

the <GraphenePlane> to initialize

normal

Passed: a <GrapheneVec3>, or #f.

a unit length normal vector defining the plane pointing towards the origin; if unset, we use the X axis by default

constant

Passed: a real number.

the distance from the origin to the plane along the normal vector; the sign determines the half-space occupied by the plane

%return

Returned: a <GraphenePlane>.

the initialized plane

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

Initializes the given <GraphenePlane> using the normal vector and constant of another <GraphenePlane>.

self

Passed: a <GraphenePlane>.

the <GraphenePlane> to initialize

src

Passed: a <GraphenePlane>.

a <GraphenePlane>

%return

Returned: a <GraphenePlane>.

the initialized plane

Method: plane:init-from-point self normal point ⇒ %return
Method: init-from-point self normal point ⇒ %return

Initializes the given <GraphenePlane> using the given normal vector and an arbitrary co-planar point.

self

Passed: a <GraphenePlane>.

the <GraphenePlane> to initialize

normal

Passed: a <GrapheneVec3>.

a normal vector defining the plane pointing towards the origin

point

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a <GraphenePlane>.

the initialized plane

Method: plane:init-from-points self a b c ⇒ %return
Method: init-from-points self a b c ⇒ %return

Initializes the given <GraphenePlane> using the 3 provided co-planar points.

The winding order is counter-clockwise, and determines which direction the normal vector will point.

self

Passed: a <GraphenePlane>.

the <GraphenePlane> to initialize

a

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

b

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

c

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a <GraphenePlane>.

the initialized plane

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

Initializes the given <GraphenePlane> using the components of the given <GrapheneVec4> vector.

self

Passed: a <GraphenePlane>.

the <GraphenePlane> to initialize

src

Passed: a <GrapheneVec4>.

a <GrapheneVec4> containing the normal vector in its first three components, and the distance in its fourth component

%return

Returned: a <GraphenePlane>.

the initialized plane

Method: plane:negate! self res ⇒ res
Method: negate! self res ⇒ res

Negates the normal vector and constant of a <GraphenePlane>, effectively mirroring the plane across the origin.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

res

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

return location for the negated plane

Method: plane:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Normalizes the vector of the given <GraphenePlane>, and adjusts the constant accordingly.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

res

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

return location for the normalized plane

Method: plane:transform! self matrix normal-matrix res ⇒ res
Method: transform! self matrix normal-matrix res ⇒ res

Transforms a <GraphenePlane> self using the given matrix and normal-matrix.

If normal-matrix is #f, a transformation matrix for the plane normal will be computed from matrix. If you are transforming multiple planes using the same matrix it’s recommended to compute the normal matrix beforehand to avoid incurring in the cost of recomputing it every time.

self

Passed: a <GraphenePlane>.

a <GraphenePlane>

matrix

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

normal-matrix

Passed: a <GrapheneMatrix>, or #f.

a <GrapheneMatrix>

res

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

the transformed plane