ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundarySphere Class Reference

Represents a spherical boundary object for motion and collision simulations. More...

#include <BoundarySphere.h>

Collaboration diagram for BoundarySphere:

Public Member Functions

 BoundarySphere (Object3D *object, float radius)
 Constructs a BoundarySphere with a given object and radius.
 
 BoundarySphere (Object3D *object, Vector3D position, float radius)
 Constructs a BoundarySphere with a given object, position, and radius.
 
float GetRadius ()
 Gets the radius of the sphere.
 
Object3DGetObject3D ()
 Gets the associated Object3D of the sphere.
 
void Update (float dT, Vector3D acceleration, Quaternion rotation)
 Updates the sphere's position and velocity based on acceleration and rotation.
 
bool IsIntersecting (BoundarySphere *bO)
 Checks if the sphere intersects with another BoundarySphere.
 
void Collide (float elasticity, BoundarySphere *bO)
 Resolves collision between this sphere and another BoundarySphere.
 

Public Attributes

Vector3D velocity = Vector3D(0, 0, 0)
 Velocity vector of the sphere.
 
Vector3D position = Vector3D(0, 0, 0)
 Current position of the sphere.
 

Private Attributes

Object3Dobject
 Pointer to the 3D object associated with the sphere.
 
Vector3D centerPosition
 Center position of the sphere.
 
Quaternion previousRotation
 Previous rotation of the sphere.
 
float radius = 1.0f
 Radius of the sphere.
 

Detailed Description

Represents a spherical boundary object for motion and collision simulations.

Definition at line 23 of file BoundarySphere.h.

Constructor & Destructor Documentation

◆ BoundarySphere() [1/2]

BoundarySphere ( Object3D object,
float  radius 
)

Constructs a BoundarySphere with a given object and radius.

Parameters
objectPointer to the Object3D associated with the sphere.
radiusRadius of the sphere.

Definition at line 3 of file BoundarySphere.cpp.

References object, position, and radius.

◆ BoundarySphere() [2/2]

BoundarySphere ( Object3D object,
Vector3D  position,
float  radius 
)

Constructs a BoundarySphere with a given object, position, and radius.

Parameters
objectPointer to the Object3D associated with the sphere.
positionInitial position of the sphere.
radiusRadius of the sphere.

Definition at line 9 of file BoundarySphere.cpp.

References object, position, and radius.

Member Function Documentation

◆ Collide()

void Collide ( float  elasticity,
BoundarySphere bO 
)

Resolves collision between this sphere and another BoundarySphere.

Parameters
elasticityElasticity coefficient for the collision.
bOPointer to the other BoundarySphere.

Definition at line 36 of file BoundarySphere.cpp.

References Vector3D::DotProduct(), IsIntersecting(), position, and velocity.

Referenced by BoundaryMotionSimulator::Update().

◆ GetObject3D()

Object3D * GetObject3D ( )

Gets the associated Object3D of the sphere.

Returns
Pointer to the Object3D.

Definition at line 19 of file BoundarySphere.cpp.

References object.

Referenced by BoundaryMotionSimulator::Update().

◆ GetRadius()

float GetRadius ( )

Gets the radius of the sphere.

Returns
Radius of the sphere.

Definition at line 15 of file BoundarySphere.cpp.

References radius.

Referenced by BoundaryCube::CollideSphere(), BoundaryCube::IsIntersecting(), and IsIntersecting().

◆ IsIntersecting()

bool IsIntersecting ( BoundarySphere bO)

Checks if the sphere intersects with another BoundarySphere.

Parameters
bOPointer to the other BoundarySphere.
Returns
True if the spheres intersect, false otherwise.

Definition at line 32 of file BoundarySphere.cpp.

References GetRadius(), position, and radius.

Referenced by Collide().

◆ Update()

void Update ( float  dT,
Vector3D  acceleration,
Quaternion  rotation 
)

Updates the sphere's position and velocity based on acceleration and rotation.

Parameters
dTTime step in seconds.
accelerationAcceleration vector applied to the sphere.
rotationRotation quaternion applied to the sphere.

Definition at line 23 of file BoundarySphere.cpp.

References Vector3D::Constrain(), Quaternion::MultiplicativeInverse(), Quaternion::Multiply(), position, previousRotation, Quaternion::RotateVector(), and velocity.

Referenced by BoundaryMotionSimulator::Update().

Member Data Documentation

◆ centerPosition

Vector3D centerPosition
private

Center position of the sphere.

Definition at line 26 of file BoundarySphere.h.

◆ object

Object3D* object
private

Pointer to the 3D object associated with the sphere.

Definition at line 25 of file BoundarySphere.h.

Referenced by BoundarySphere(), BoundarySphere(), and GetObject3D().

◆ position

Vector3D position = Vector3D(0, 0, 0)

Current position of the sphere.

Definition at line 32 of file BoundarySphere.h.

Referenced by BoundarySphere(), BoundarySphere(), Collide(), BoundaryCube::CollideSphere(), BoundaryCube::IsIntersecting(), IsIntersecting(), and Update().

◆ previousRotation

Quaternion previousRotation
private

Previous rotation of the sphere.

Definition at line 27 of file BoundarySphere.h.

Referenced by Update().

◆ radius

float radius = 1.0f
private

Radius of the sphere.

Definition at line 28 of file BoundarySphere.h.

Referenced by BoundarySphere(), BoundarySphere(), GetRadius(), and IsIntersecting().

◆ velocity

Vector3D velocity = Vector3D(0, 0, 0)

Velocity vector of the sphere.

Definition at line 31 of file BoundarySphere.h.

Referenced by Collide(), BoundaryCube::CollideSphere(), BoundaryMotionSimulator::Randomize(), BoundaryMotionSimulator::Update(), and Update().


The documentation for this class was generated from the following files: