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

Simulates motion and collision interactions between a BoundaryCube and multiple BoundarySpheres. More...

#include <BoundaryMotionSimulator.h>

Collaboration diagram for BoundaryMotionSimulator:

Public Member Functions

 BoundaryMotionSimulator (Object3D **objects, int objectCount, BoundaryCube *bC, float radius, float elasticity)
 Constructs a BoundaryMotionSimulator.
 
void Randomize (float range)
 Randomizes the velocities of all boundary spheres within a specified range.
 
Vector3D RandomRatio (float range)
 Generates a randomized vector with ratios for X, Y, and Z axes.
 
void Update (float dT, Vector3D acceleration, Quaternion rotation)
 Updates the simulation by applying physics and resolving collisions.
 

Private Attributes

BoundaryCubebC
 Pointer to the boundary cube.
 
BoundarySphere ** bS
 Array of pointers to the boundary spheres.
 
int sphereCount
 Number of boundary spheres.
 
float elasticity = 0.8f
 Elasticity coefficient for collisions.
 

Detailed Description

Simulates motion and collision interactions between a BoundaryCube and multiple BoundarySpheres.

Definition at line 25 of file BoundaryMotionSimulator.h.

Constructor & Destructor Documentation

◆ BoundaryMotionSimulator()

BoundaryMotionSimulator ( Object3D **  objects,
int  objectCount,
BoundaryCube bC,
float  radius,
float  elasticity 
)

Constructs a BoundaryMotionSimulator.

Parameters
objectsArray of Object3D pointers representing the objects.
objectCountNumber of objects in the simulation.
bCPointer to the boundary cube.
radiusRadius of the boundary spheres.
elasticityElasticity coefficient for collisions.

Definition at line 3 of file BoundaryMotionSimulator.cpp.

References bC, bS, elasticity, and sphereCount.

Member Function Documentation

◆ Randomize()

void Randomize ( float  range)

Randomizes the velocities of all boundary spheres within a specified range.

Parameters
rangeMaximum velocity range (mm/s).

Definition at line 14 of file BoundaryMotionSimulator.cpp.

References bS, sphereCount, BoundarySphere::velocity, Vector3D::X, Vector3D::Y, and Vector3D::Z.

Referenced by PhysicsSimulator::PhysicsSimulator().

◆ RandomRatio()

Vector3D RandomRatio ( float  range)

Generates a randomized vector with ratios for X, Y, and Z axes.

Parameters
rangeMaximum range for each axis ratio.
Returns
A randomized Vector3D.

Definition at line 22 of file BoundaryMotionSimulator.cpp.

References Vector3D::X, Vector3D::Y, and Vector3D::Z.

Referenced by Update().

◆ Update()

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

Updates the simulation by applying physics and resolving collisions.

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

Definition at line 30 of file BoundaryMotionSimulator.cpp.

References bC, bS, BoundarySphere::Collide(), BoundaryCube::CollideSphere(), elasticity, BoundarySphere::GetObject3D(), Object3D::GetTransform(), RandomRatio(), Object3D::ResetVertices(), Transform::SetPosition(), sphereCount, BoundarySphere::Update(), and BoundarySphere::velocity.

Referenced by PhysicsSimulator::Update().

Member Data Documentation

◆ bC

BoundaryCube* bC
private

Pointer to the boundary cube.

Definition at line 27 of file BoundaryMotionSimulator.h.

Referenced by BoundaryMotionSimulator(), and Update().

◆ bS

BoundarySphere** bS
private

Array of pointers to the boundary spheres.

Definition at line 28 of file BoundaryMotionSimulator.h.

Referenced by BoundaryMotionSimulator(), Randomize(), and Update().

◆ elasticity

float elasticity = 0.8f
private

Elasticity coefficient for collisions.

Definition at line 30 of file BoundaryMotionSimulator.h.

Referenced by BoundaryMotionSimulator(), and Update().

◆ sphereCount

int sphereCount
private

Number of boundary spheres.

Definition at line 29 of file BoundaryMotionSimulator.h.

Referenced by BoundaryMotionSimulator(), Randomize(), and Update().


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