GCubeSDK
©2026 FenixFox®Studios

Sphere

Class representing a sphere in 3D space.
An analytical 3D sphere defined by a center and radius. This class is mainly used as a Bounding Sphere for 3D objects.

Methods

Sphere(const Vector3& center, f32 radius)

Constructor to create new sphere

center Center of the sphere Vector3()
radius Radius of the sphere -1.0f

Sphere& set(const Vector3& center, f32 radius)

Sets the sphere's components by copying the given values.

center The center of the sphere
radius The radius of the sphere

Sphere& setFromPoints(const vector<Vector3>& points, const Vector3& center)

Sets the sphere to contain all points in the array

points A list of points in 3D space
center The center of the sphere

Sphere& clone() const

Returns a new Sphere with the same center and radius as this one

Sphere& copy(const Sphere& sphere)

Copies the values from sphere to this sphere

sphere Sphere to copy from

Sphere& makeEmpty()

Makes this sphere empty

bool isEmpty() const

Returns true if this sphere includes zero points within its radius

Sphere& expandByPoint(const Vector3& point)

Expands the boundaries of this sphere to include point

point Vector3 that should be included in the sphere

bool containsPoint(const Vector3& point) const

Returns true if the specified point lies within or on the boundaries

point Vector3 to check for inclusion

bool containsSphere(const Vector3& sphere) const

Returns true if the specified sphere lies within or on the boundaries

sphere Sphere to check for inclusion

Vector3& clampPoint(const Vector3& point, Vector3& target) const

Calculate the clamp point within the bounds of this sphere if needed

point Vector3 to clamp
target Result will be copied into this Vector3

f32 distanceToPoint(const Vector3& point) const

Returns the distance from the boundary of the sphere to the given point.

point Vector3 to measure distance to

bool intersectsBox(const Sphere& sphere) const

Determines whether or not this sphere intersects box

sphere Box to check for intersection against

bool intersectsSphere(const Sphere& sphere) const

Determines whether or not this sphere intersects sphere

sphere Sphere to check for intersection against

bool intersectsPlane(const Plane& plane) const

Determines whether or not this sphere intersects plane

plane Plane to check for intersection against

bool intersectsTriangle(const Triangle& triangle) const

Determines whether or not this sphere intersects triangle

triangle Triangle to check for intersection against

Sphere& applyMatrix4(const Matrix4& matrix)

Transforms this Sphere with the supplied matrix

matrix Matrix4 to apply

Sphere& translate(const Vector3& offset)

Adds offset to the bounds of this sphere

offset Direction and distance of offset

Sphere& unionSphere(const Sphere& sphere)

Expands this sphere to enclose both spheres

sphere Sphere that will be unioned with this sphere

Box3& getBoundingBox(Box3& target) const

Gets a Box that bounds the sphere

target Result will be copied into this Box

bool equals(const Sphere& sphere) const

Returns true if this sphere and sphere share the same bounds

sphere Sphere to compare with this one

bool operator==(const Sphere& sphere) const

Checks if this sphere equals another

sphere Sphere to compare with

bool operator!=(const Sphere& sphere) const

Checks if this sphere does not equal another

sphere Sphere to compare with

Properties

center Vector3 Center of the sphere
radius f32 Radius of the sphere
isSphere bool Read
name string Optional display name
id u32 Unique identifier
uuid string UUID string
enabled bool Active/inactive
version u32 Bumps on change