Yields a force function that applies the thing's acceleration.x to its angular acceleration.
Yields a force function that applies the thing's velocity to its angle. This will mean it points in the direction of travel.
Sets angle, angularVelocity and angularAcceleration based on angularAcceleration, angularVelocity, angle
Apply a series of force functions or forces to t
. Null/undefined entries are skipped silently.
It also updates the velocity and position of the returned version of t
.
For a given set of attractors, returns a function that a sets acceleration of attractee.
Keep note though that this bakes-in the values of the attractor, it won't reflect changes to their state. For dynamic
attractors, it might be easier to use computeAttractionForce
.
Returns the acceleration to get from currentPos
to targetPos
.
Computes the attraction force between two things.
Value for gravity
will depend on what range is used for mass
. It's probably a good idea
to keep mass to mean something relative - ie 1 is 'full' mass, and adjust the gravity
value until it behaves as you like. Keeping mass in 0..1 range makes it easier to apply to
visual properties later.
Compute a position based on distance and angle from origin
Compute a new position based on existing position and velocity vector
Compute velocity based on acceleration and current velocity
constrainBounce
yields a function that affects t
's position and velocity such that it
bounces within bounds.
Throws an error if t
is not of the ForceAffected
shape.
A force based on the square of the thing's velocity. It's like velocityForce, but here the velocity has a bigger impact.
Null force does nothing
A force that orients things according to direction of travel.
The pendulum force swings something back and forth.
Spring force
A force that moves a thing toward targetPos
.
Force calculated from velocity of object. Reads velocity and influences acceleration.
Basic properties of a thing that can be affected by forces
A function that updates values of a thing.
A vector to apply to acceleration or a force function
Logic for applying mass
Pendulum force options
Apples
vector
to acceleration, scaling according to mass, based on themass
option. It returns a function which can later be applied to a thing.