Package toxi.physics3d
Class VerletParticle3D
java.lang.Object
toxi.geom.Vec3D
toxi.physics3d.VerletParticle3D
- All Implemented Interfaces:
Comparable<ReadonlyVec3D>
,ReadonlyVec3D
An individual 3D particle for use by the VerletPhysics and VerletSpring
classes. A particle has weight, can be locked in space and its position
constrained inside an (optional) axis-aligned bounding box.
-
Nested Class Summary
Nested classes/interfaces inherited from class toxi.geom.Vec3D
Vec3D.Axis
-
Field Summary
Modifier and TypeFieldDescriptionBounding box, by default set to null to disableAn optional particle constraints, called immediately after a particle is updated (and only used if particle is unlocked (default) -
Constructor Summary
ConstructorDescriptionVerletParticle3D
(float x, float y, float z) Creates particle at position xyzVerletParticle3D
(float x, float y, float z, float w) Creates particle at position xyz with weight wCreates particle at the position of the passed in vectorVerletParticle3D
(ReadonlyVec3D v, float w) Creates particle with weight w at the position of the passed in vectorCreates a copy of the passed in particle -
Method Summary
Modifier and TypeMethodDescriptionaddBehavior
(ParticleBehavior3D behavior) addBehavior
(ParticleBehavior3D behavior, float timeStep) Adds the given constraint implementation to the list of constraints applied to this particle at each time step.addVelocity
(Vec3D v) void
void
Removes any currently applied constraints from this particle.final float
Returns the particle's position at the most recent time step.final float
final boolean
isLocked()
lock()
Locks/immobilizes particle in spaceboolean
boolean
Attempts to remove the given constraint instance from the list of active constraints.scaleVelocity
(float scl) void
setWeight
(float w) unlock()
Unlocks particle againvoid
update()
Methods inherited from class toxi.geom.Vec3D
abs, add, add, add, addSelf, addSelf, addSelf, angleBetween, angleBetween, clear, compareTo, constrain, constrain, copy, cross, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, dot, equals, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getCartesian, getClosestAxis, getComponent, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getMapped, getNormalized, getNormalizedTo, getReciprocal, getReflected, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getRoundedTo, getSignum, getSpherical, hashCode, headingXY, headingXZ, headingYZ, immutable, interpolateTo, interpolateTo, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isMajorAxis, isZeroVector, jitter, jitter, jitter, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, reflect, rotateAroundAxis, rotateX, rotateY, rotateZ, roundTo, scale, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, scaleSelf, set, set, set, setComponent, setComponent, setX, setXY, setY, setZ, shuffle, signum, snapToAxis, sub, sub, sub, subSelf, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, to4D, to4D, toArray, toArray4, toCartesian, toSpherical, toString, x, y, z
-
Field Details
-
bounds
Bounding box, by default set to null to disable -
constraints
An optional particle constraints, called immediately after a particle is updated (and only used if particle is unlocked (default) -
behaviors
-
-
Constructor Details
-
VerletParticle3D
public VerletParticle3D(float x, float y, float z) Creates particle at position xyz- Parameters:
x
-y
-z
-
-
VerletParticle3D
public VerletParticle3D(float x, float y, float z, float w) Creates particle at position xyz with weight w- Parameters:
x
-y
-z
-w
-
-
VerletParticle3D
Creates particle at the position of the passed in vector- Parameters:
v
- position
-
VerletParticle3D
Creates particle with weight w at the position of the passed in vector- Parameters:
v
- positionw
- weight
-
VerletParticle3D
Creates a copy of the passed in particle- Parameters:
p
-
-
-
Method Details
-
addBehavior
-
addBehavior
-
addConstraint
Adds the given constraint implementation to the list of constraints applied to this particle at each time step.- Parameters:
c
- constraint instance- Returns:
- itself
-
addForce
-
addVelocity
-
applyBehaviors
public void applyBehaviors() -
applyConstraints
public void applyConstraints() -
clearConstraints
Removes any currently applied constraints from this particle.- Returns:
- itself
-
clearForce
-
clearVelocity
-
getInvWeight
public final float getInvWeight()- Returns:
- the inverse weight (1/weight)
-
getPreviousPosition
Returns the particle's position at the most recent time step.- Returns:
- previous position
-
getVelocity
-
getWeight
public final float getWeight()- Returns:
- the weight
-
isLocked
public final boolean isLocked()- Returns:
- true, if particle is locked
-
lock
Locks/immobilizes particle in space- Returns:
- itself
-
removeBehavior
-
removeConstraint
Attempts to remove the given constraint instance from the list of active constraints.- Parameters:
c
- constraint to remove- Returns:
- true, if successfully removed
-
scaleVelocity
-
setPreviousPosition
-
setWeight
public void setWeight(float w) -
unlock
Unlocks particle again- Returns:
- itself
-
update
public void update()
-