|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Constrains a particle's angular position around an anchor. More...
#include <Constrainer.hpp>

Public Member Functions | |
| AngleConstrainer (std::shared_ptr< Particle > anchor, std::shared_ptr< Particle > particle) | |
| Construct with automatic intervals set to initial angles. | |
| AngleConstrainer (std::shared_ptr< Particle > anchor, std::shared_ptr< Particle > particle, const Interval< Radian > &theta_interval) | |
| Construct with custom theta interval, phi fixed to initial value. | |
| AngleConstrainer (std::shared_ptr< Particle > anchor, std::shared_ptr< Particle > particle, const Interval< Radian > &theta_interval, const Interval< Radian > &phi_interval) | |
| Construct with custom theta and phi intervals. | |
| void | Correct (const Quantity< Second > dt) const |
| Correct velocity to satisfy angular constraints (Velocity Constrain) | |
Private Member Functions | |
| void | IntervalCheck () const |
| Validate that angle intervals are within [-2pi, 2pi]. | |
Private Attributes | |
| std::shared_ptr< Particle > | anchor_ |
| std::shared_ptr< Particle > | particle_ |
| Interval< Radian > | theta_interval_ |
| Interval< Radian > | phi_interval_ |
Constrains a particle's angular position around an anchor.
AngleConstrainer restricts the polar angle (theta) and azimuthal angle (phi) of a particle relative to an anchor point. Both angles are constrained within user-specified intervals.
Angles are wrapped to [-2pi, 2pi] before validation, so intervals should be specified in this range.
Example: auto anchor = std::make_shared<Particle>(1_kg, Vector3{0_m, 0_m, 0_m}); auto particle = std::make_shared<Particle>(1_kg, Vector3{1_m, 0_m, 0_m});
// Restrict theta to [30deg, 60deg], phi to [-45deg, 45deg] Interval<Radian> theta_range(30.0_deg, 60.0_deg); Interval<Radian> phi_range(-45.0_deg, 45.0_deg); AngleConstrainer constraint(anchor, particle, theta_range, phi_range);
// In simulation loop: constraint.Correct(dt);
Note: Theta is the polar angle from the Z axis (0 to pi in standard spherical coordinates). Phi is the azimuthal angle from the X axis.
Definition at line 135 of file Constrainer.hpp.
|
inline |
Construct with automatic intervals set to initial angles.
Both theta and phi intervals are fixed to the particle's initial angles.
| anchor | The fixed reference point |
| particle | The particle to constrain |
Definition at line 145 of file Constrainer.hpp.
|
inline |
Construct with custom theta interval, phi fixed to initial value.
| anchor | The fixed reference point |
| particle | The particle to constrain |
| theta_interval | Allowed range for polar angle (radians) |
| std::invalid_argument | If interval bounds exceed [-2pi, 2pi] |
Definition at line 161 of file Constrainer.hpp.
|
inline |
Construct with custom theta and phi intervals.
| anchor | The fixed reference point |
| particle | The particle to constrain |
| theta_interval | Allowed range for polar angle (radians) |
| phi_interval | Allowed range for azimuthal angle (radians) |
| std::invalid_argument | If interval bounds exceed [-2pi, 2pi] |
Definition at line 178 of file Constrainer.hpp.
Correct velocity to satisfy angular constraints (Velocity Constrain)
The particle's position is adjusted to the nearest valid angle if it falls outside the specified intervals. Both theta and phi are wrapped to [-2pi, 2pi] before validation.
The correction uses the particle's current distance from the anchor (preserved during angular correction) and adjusts velocity accordingly.
| dt | Time step used for velocity correction |
If the particle is exactly at the anchor (length == 0), no correction is applied.
Definition at line 199 of file Constrainer.hpp.
|
inlineprivate |
Validate that angle intervals are within [-2pi, 2pi].
| std::invalid_argument | If any interval bound exceeds [-2pi, 2pi] |
Angles are wrapped to this range before validation, so intervals must be specified within this range.
Definition at line 258 of file Constrainer.hpp.
|
private |
Definition at line 244 of file Constrainer.hpp.
|
private |
Definition at line 245 of file Constrainer.hpp.
Definition at line 248 of file Constrainer.hpp.
Definition at line 247 of file Constrainer.hpp.