MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ orbital()

VectorField MayaFlux::Kinesis::ForceFields::orbital ( const glm::vec3 &  anchor,
const glm::vec3 &  axis,
float  strength 
)
inline

Tangential force perpendicular to both an axis and the radius vector.

Parameters
anchorPoint the orbit is centred on.
axisOrbital axis (e.g. glm::vec3(0, 1, 0) for orbits in the XZ plane).
strengthForce magnitude, constant with distance.
Returns
VectorField: glm::vec3 -> glm::vec3

cross(axis, p - anchor) is perpendicular to the radius vector in the plane normal to axis, which is the direction that turns radial motion into revolution rather than a straight collapse or escape. Combine with point_attractor on the same anchor for an orbit: attraction supplies the centripetal pull, this supplies the sideways push that keeps the fall from being straight down. Unlike a true two-body problem this is force-based rather than velocity-constrained, so orbits drift rather than close exactly, which reads as organic rather than as a bug.

Definition at line 46 of file ForceFields.hpp.

47{
48 return { .fn = [anchor, axis, strength](const glm::vec3& p) -> glm::vec3 {
49 glm::vec3 radius = p - anchor;
50 glm::vec3 tangent = glm::cross(axis, radius);
51 float d = glm::length(tangent);
52 if (d < 0.001F)
53 return glm::vec3(0.0F);
54 return (tangent / d) * strength;
55 } };
56}
float radius

References MayaFlux::Kinesis::Tendency< D, R >::fn, and radius.