19 TypeHandle LinearCylinderVortexForce::_type_handle;
26 PN_stdfloat a,
bool md) :
28 _radius(radius), _length(length), _coef(coef) {
37 _radius = copy._radius;
38 _length = copy._length;
60 LVector3 LinearCylinderVortexForce::
65 LVector3 force_vec(0.0f, 0.0f, 0.0f);
71 if (point[2] < 0.0f || point[2] > _length)
75 PN_stdfloat x_squared = point[0] * point[0];
76 PN_stdfloat y_squared = point[1] * point[1];
77 PN_stdfloat dist_squared = x_squared + y_squared;
78 PN_stdfloat radius_squared = _radius * _radius;
82 if (dist_squared > radius_squared)
85 if IS_NEARLY_ZERO(dist_squared)
88 PN_stdfloat r = csqrt(dist_squared);
93 LVector3 tangential = point;
95 tangential.normalize();
96 tangential = tangential.cross(LVector3(0,0,1));
98 LVector3 centripetal = -point;
99 centripetal[2] = 0.0f;
100 centripetal.normalize();
102 LVector3 combined = tangential + centripetal;
103 combined.normalize();
108 centripetal = combined * _coef * po->
get_velocity().length();
122 out<<
"LinearCylinderVortexForce";
132 out.width(
indent); out<<
""; out<<
"LinearCylinderVortexForce:\n";
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
A body on which physics will be applied.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A force that acts on a PhysicsObject by way of an Integrator.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
LVector3 get_velocity() const
Velocity Query per second.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
LPoint3 get_position() const
Position Query.
virtual void output(std::ostream &out) 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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.