ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundaryMotionSimulator.h
Go to the documentation of this file.
1/**
2 * @file BoundaryMotionSimulator.h
3 * @brief Defines the BoundaryMotionSimulator class for simulating motion and collisions of boundary objects.
4 *
5 * The BoundaryMotionSimulator class manages the simulation of motion, collisions, and interactions
6 * between a boundary cube and multiple boundary spheres in 3D space. Includes randomized velocity and acceleration.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../../Utils/Math/Rotation.h"
16#include "../../Utils/Math/Vector3D.h"
17#include "../../Scene/Objects/Object3D.h"
18#include "BoundaryCube.h"
19#include "BoundarySphere.h"
20
21/**
22 * @class BoundaryMotionSimulator
23 * @brief Simulates motion and collision interactions between a BoundaryCube and multiple BoundarySpheres.
24 */
26private:
27 BoundaryCube* bC; ///< Pointer to the boundary cube.
28 BoundarySphere** bS; ///< Array of pointers to the boundary spheres.
29 int sphereCount; ///< Number of boundary spheres.
30 float elasticity = 0.8f; ///< Elasticity coefficient for collisions.
31
32public:
33 /**
34 * @brief Constructs a BoundaryMotionSimulator.
35 * @param objects Array of Object3D pointers representing the objects.
36 * @param objectCount Number of objects in the simulation.
37 * @param bC Pointer to the boundary cube.
38 * @param radius Radius of the boundary spheres.
39 * @param elasticity Elasticity coefficient for collisions.
40 */
41 BoundaryMotionSimulator(Object3D** objects, int objectCount, BoundaryCube* bC, float radius, float elasticity);
42
43 /**
44 * @brief Randomizes the velocities of all boundary spheres within a specified range.
45 * @param range Maximum velocity range (mm/s).
46 */
47 void Randomize(float range);
48
49 /**
50 * @brief Generates a randomized vector with ratios for X, Y, and Z axes.
51 * @param range Maximum range for each axis ratio.
52 * @return A randomized Vector3D.
53 */
54 Vector3D RandomRatio(float range);
55
56 /**
57 * @brief Updates the simulation by applying physics and resolving collisions.
58 * @param dT Time step in seconds.
59 * @param acceleration Acceleration vector applied to the spheres.
60 * @param rotation Rotation quaternion applied to the spheres.
61 */
62 void Update(float dT, Vector3D acceleration, Quaternion rotation);
63};
Defines the BoundaryCube class for representing and managing axis-aligned bounding cubes.
Defines the BoundarySphere class for simulating spherical boundary objects.
Represents an axis-aligned bounding cube for collision detection and physics.
Simulates motion and collision interactions between a BoundaryCube and multiple BoundarySpheres.
void Randomize(float range)
Randomizes the velocities of all boundary spheres within a specified range.
void Update(float dT, Vector3D acceleration, Quaternion rotation)
Updates the simulation by applying physics and resolving collisions.
int sphereCount
Number of boundary spheres.
float elasticity
Elasticity coefficient for collisions.
Vector3D RandomRatio(float range)
Generates a randomized vector with ratios for X, Y, and Z axes.
BoundarySphere ** bS
Array of pointers to the boundary spheres.
BoundaryCube * bC
Pointer to the boundary cube.
Represents a spherical boundary object for motion and collision simulations.
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26