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

◆ point_attractor()

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

Radial attraction/repulsion toward an anchor point.

Parameters
anchorTarget position
strengthForce magnitude scalar (positive attracts, negative repels)
Returns
VectorField: glm::vec3 -> glm::vec3

Force magnitude follows inverse square: strength / max(d², floor). Direction is normalized delta from evaluation point to anchor. Floor of 0.1 prevents singularity at the anchor position.

Definition at line 19 of file ForceFields.hpp.

20{
21 return { .fn = [anchor, strength](const glm::vec3& p) -> glm::vec3 {
22 glm::vec3 delta = anchor - p;
23 float d = glm::length(delta);
24 if (d < 0.001F)
25 return glm::vec3(0.0F);
26 return (delta / d) * (strength / std::max(d * d, 0.1F));
27 } };
28}

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

Referenced by MayaFlux::Nodes::Network::PhysicsOperator::apply_attraction_forces().

+ Here is the caller graph for this function: