1.13 <GrapheneSphere>

Structure: <GrapheneSphere>

A sphere, represented by its center and radius.

Procedures

Procedure: sphere:alloc ⇒ %return

Allocates a new <GrapheneSphere>.

The contents of the newly allocated structure are undefined.

%return

Returned: a <GrapheneSphere>.

the newly allocated <GrapheneSphere>. Use sphere:free to free the resources allocated by this function

Method: sphere:contains-point? self point ⇒ %return
Method: contains-point? self point ⇒ %return

Checks whether the given point is contained in the volume of a <GrapheneSphere>.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

point

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a boolean.

true if the sphere contains the point

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

Computes the distance of the given point from the surface of a <GrapheneSphere>.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

point

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

%return

Returned: a real number.

the distance of the point

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

Checks whether two <GrapheneSphere> are equal.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

b

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

%return

Returned: a boolean.

true if the spheres are equal

Method: sphere:free self
Method: free self

Frees the resources allocated by sphere:alloc.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

Method: sphere:get-bounding-box! self box ⇒ box
Method: get-bounding-box! self box ⇒ box

Computes the bounding box capable of containing the given <GrapheneSphere>.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

box

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

return location for the bounding box

Method: sphere:get-center! self center ⇒ center
Method: get-center! self center ⇒ center

Retrieves the coordinates of the center of a <GrapheneSphere>.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

center

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

return location for the coordinates of the center

Method: sphere:get-radius self ⇒ %return
Method: get-radius self ⇒ %return

Retrieves the radius of a <GrapheneSphere>.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

%return

Returned: a real number.

Method: sphere:init self center radius ⇒ %return
Method: init self center radius ⇒ %return

Initializes the given <GrapheneSphere> with the given center and radius.

self

Passed: a <GrapheneSphere>.

the <GrapheneSphere> to initialize

center

Passed: a <GraphenePoint3D>, or #f.

the coordinates of the center of the sphere, or #f for a center in (0, 0, 0)

radius

Passed: a real number.

the radius of the sphere

%return

Returned: a <GrapheneSphere>.

the initialized <GrapheneSphere>

Method: sphere:init-from-points self points [center] ⇒ %return
Method: init-from-points self points [center] ⇒ %return

Initializes the given <GrapheneSphere> using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all points.

self

Passed: a <GrapheneSphere>.

the <GrapheneSphere> to initialize

points

Passed: a list or vector, each a <GraphenePoint3D>.

an array of <GraphenePoint3D>

center

Passed, or left out: a <GraphenePoint3D>, or #f.

the center of the sphere

%return

Returned: a <GrapheneSphere>.

the initialized <GrapheneSphere>

n-points

Not passed: guile-gi gives the length of points.

the number of <GraphenePoint3D> in the points array

Method: sphere:init-from-vectors self vectors [center] ⇒ %return
Method: init-from-vectors self vectors [center] ⇒ %return

Initializes the given <GrapheneSphere> using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all vectors.

self

Passed: a <GrapheneSphere>.

the <GrapheneSphere> to initialize

vectors

Passed: a list or vector, each a <GrapheneVec3>.

an array of <GrapheneVec3>

center

Passed, or left out: a <GraphenePoint3D>, or #f.

the center of the sphere

%return

Returned: a <GrapheneSphere>.

the initialized <GrapheneSphere>

n-vectors

Not passed: guile-gi gives the length of vectors.

the number of <GrapheneVec3> in the vectors array

Method: sphere:is-empty? self ⇒ %return
Method: is-empty? self ⇒ %return

Checks whether the sphere has a zero radius.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

%return

Returned: a boolean.

true if the sphere is empty

Method: sphere:translate! self point res ⇒ res
Method: translate! self point res ⇒ res

Translates the center of the given <GrapheneSphere> using the point coordinates as the delta of the translation.

self

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

point

Passed: a <GraphenePoint3D>.

the coordinates of the translation

res

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

return location for the translated sphere