WorldBoundSphere Class
This class serves to construct the bounding sphere in double precision coordinates.
By using this class you can easily find the common bounding sphere for several objects by expanding the bounding sphere.
WorldBoundSphere Class
Members
WorldBoundSphere()
Constructor. Creates an empty bounding sphere.void set(variable v)
Depending on the variable passed as an argument, the function sets the bounding sphere by the given bounding sphere or the bounding box.Arguments
- variable v - Argument of one of the following types:
- WorldBoundSphere bs - The bounding sphere.
- WorldBoundBox bb - The bounding box.
void set(variable v0, variable v1)
Sets the bounding sphere. The function can receive the following arguments:- dvec3 and double - coordinates of the sphere center and its radius.
- WorldBoundSphere and dmat4 - the bounding sphere and its transformation matrix.
Arguments
- variable v0 - Argument of one of the following types:
- dvec3 point - Coordinates of the sphere center.
- WorldBoundSphere bs - The bounding sphere.
- variable v1 - Argument of one of the following types:
- double radius - The bounding sphere radius.
- mat4 transform - Transformation matrix of the bounding sphere.
dvec3 getCenter()
Returns coordinates of the bounding sphere center.Return value
Coordinates of the sphere center.double getRadius()
Returns the radius of the bounding sphere.Return value
Radius of the sphere.int isValid()
Checks if the bounding sphere radius has a positive value.Return value
1 if the radius is positive; otherwise, 0.void expand(variable v)
Depending on the variables passed as arguments, the function performs the following:- If dvec3 is passed, the function expands the current bounding sphere so that the given point is inside this bounding sphere.
- If WorldBoundSphere is passed, the function expands the current bounding sphere so that it can be described around the given bounding sphere.
- If WorldBoundBox is passed, the function expands the current bounding sphere so that it can be described around the given bounding box.
Arguments
- variable v - Argument of one of the following types:
- dvec3 point - Coordinates of the point.
- WorldBoundSphere bs - The bounding sphere.
- WorldBoundBox bb - The bounding box.
int inside(variable v)
Depending on the variable passed as an argument, the function performs the following:- If dvec3 is passed, the function checks if the given point is inside the current bounding sphere.
- If BoundBox is passes, the function checks if the given bounding box is inside the current bounding sphere.
- If BoundSphere is passed, the function checks if the given bounding sphere is inside the current bounding sphere.
Arguments
- variable v - Argument of one of the following types:
- dvec3 point - Coordinates of the point.
- WorldBoundSphere bs - The bounding sphere.
- WorldBoundBox bb - The bounding box.
Return value
1 if the point / bounding box / bounding sphere is inside the current bounding sphere; otherwise, 0.int inside(variable v0, variable v1)
Checks if the specified sphere of box is inside the current bounding box. Variables, passed as arguments, can be the following:- dvec3 point and double radius
- dvec3 min and dvec3 max
Arguments
- variable v0 - Argument of one of the following types:
- dvec3 point - Coordinates of the sphere center.
- dvec3 min - Bounding box minimum coordinates.
- variable v1 - Argument of one of the following types:
- double radius - The sphere radius.
- dvec3 max - Bounding box maximum coordinates.
Return value
1 if the sphere / box is inside the bounding sphere; otherwise, 0.int insideAll(variable v)
Checks if the given bounding sphere / box is inside the current bounding sphere.Arguments
- variable v - Argument of one of the following types:
- WorldBoundSphere bs - The bounding sphere.
- WorldBoundBox bb - The bounding box.
Return value
1 if the bounding sphere / box is inside the current bounding sphere; otherwise, 0.WorldBoundSphere(variable v)
Constructor. Creates a bounding sphere initialized by one of the following:- WorldBoundBox - the bounding box.
- WorldBoundSphere - the bounding sphere.
Arguments
- variable v - Variable of one of the following types:
- WorldBoundBox bb - The bounding box.
- WorldBoundSphere bs - The bounding sphere.
WorldBoundSphere(variable v0, variable v1)
Constructor. Creates a bounding sphere initialized by one of the following:- dvec3 and float - the center and radius of the bounding sphere.
- BoundSphere and mat4 - the bounding sphere and its transformation matrix.
Arguments
- variable v0 - Argument of one of the following types:
- dvec3 point - Coordinates of the sphere center.
- BoundSphere bs - The bounding sphere.
- variable v1 - Argument of one of the following types:
- float radius - Radius of the bounding sphere.
- mat4 transform - Transformation matrix.
Last update: 2018-08-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)