15 #include "config_physics.h" 16 #include "linearCylinderVortexForce.h" 17 #include "nearly_zero.h" 20 TypeHandle LinearCylinderVortexForce::_type_handle;
29 PN_stdfloat a,
bool md) :
31 _radius(radius), _length(length), _coef(coef) {
42 _radius = copy._radius;
43 _length = copy._length;
78 LVector3 force_vec(0.0f, 0.0f, 0.0f);
84 if (point[2] < 0.0f || point[2] > _length)
88 PN_stdfloat x_squared = point[0] * point[0];
89 PN_stdfloat y_squared = point[1] * point[1];
90 PN_stdfloat dist_squared = x_squared + y_squared;
91 PN_stdfloat radius_squared = _radius * _radius;
95 if (dist_squared > radius_squared)
98 if IS_NEARLY_ZERO(dist_squared)
101 PN_stdfloat r = csqrt(dist_squared);
107 tangential[2] = 0.0f;
109 tangential = tangential.cross(
LVector3(0,0,1));
112 centripetal[2] = 0.0f;
115 LVector3 combined = tangential + centripetal;
139 out<<
"LinearCylinderVortexForce";
150 write(ostream &out,
unsigned int indent)
const {
152 out.width(indent); out<<
""; out<<
"LinearCylinderVortexForce:\n";
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
LinearCylinderVortexForce(PN_stdfloat radius=1.0f, PN_stdfloat length=0.0f, PN_stdfloat coef=1.0f, PN_stdfloat a=1.0f, bool md=false)
Simple Constructor.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
A body on which physics will be applied.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
A force that acts on a PhysicsObject by way of an Integrator.
LVector3 get_velocity() const
Velocity Query per second.
float length() const
Returns the length of the vector, by the Pythagorean theorem.
LPoint3 get_position() const
Position Query.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
Defines a cylinder inside of which all forces are tangential to the theta of the particle wrt the z-a...
TypeHandle is the identifier used to differentiate C++ class types.
virtual ~LinearCylinderVortexForce()
Destructor.
bool normalize()
Normalizes the vector in place.