Quote:
Originally Posted by Ether
Code:
omega = ((sFR*cos(atan2(W,L)+pi/2-aFR)+sFL*cos(atan2(-W,L)+pi/2-aFL)
+sRL*cos(atan2(-W,-L)+pi/2-aRL)+sRR*cos(atan2(W,-L)+pi/2-aRR))/4)/
(sqrt(L^2+W^2)/2);
|
This is what I have confirmed the omega equation to be:
Code:
const double omega = (((_.sFR*cos(atan2(W,L)+(HP-_.aFR))/4)+
(_.sFL*cos(atan2(-W,L)+(HP-_.aFL))/4)+
(_.sRL*cos(atan2(-W,-L)+(HP-_.aRL))/4)+
(_.sRR*cos(atan2(W,-L)+(HP-_.aRR))/4)));
Since it is just about Christmas I'll show you a similar equation I wrote (that helped me figure this one out)... This is what I use when appling a vectored force to a point within a rigid body.
Code:
void PhysicsEntity_2D::ApplyFractionalForce( const osg::Vec2d &force, const osg::Vec2d &point,double FrameDuration )
{
//Use this as a "get by" if the code doesn't work properly
#if 0
ApplyFractionalForce(force,FrameDuration);
return;
#endif
//Here is a rough draft to solve in 2 dimensions
//A=atan2(py,px) point
//M=pi/2 - A
//L=atan2(fy,fx) force
//N=L+M
//Y=sin(N)*f.length = contribution for force
//X=cos(N)*f.length = contribution for torque
double TorqueToApply;
osg::Vec2d ForceToApply;
double RadialArmDistance;
{
double A=atan2(point[1],point[0]);
double M=(M_PI/2) - A;
double L=atan2(-force[1],-force[0]);
double N=L+M;
double ForceLength= sqrt((force[1]*force[1])+(force[0]*force[0]));
RadialArmDistance= sqrt((point[1]*point[1])+(point[0]*point[0]));
//I've reserved a special case for ships which haven't specified their radius size, in which case we simply factor out the radial arm too
if ((m_RadiusOfConcentratedMass==1.0)&&(RadialArmDistance>1.0)) RadialArmDistance=1.0;
//Fr = t ... We should multiply force by the radial arm distance to get the torque
//but instead, we pass it off to physics where the multiply gets applied directly against the Radius of Concentrated Mass
//We could multiply here but doing it the other way keeps the torque value low, which also makes it easier to debug
TorqueToApply=(cos(N)*ForceLength);
}
osg::Vec2d vecToCenter = -point;
//Note we should be able to support a point set at 0,0,0 in which case we use the force itself as the direction... otherwise a zero'd point
//results in a zero'd vector which would omit applying the force
if (vecToCenter.length2()==0.0)
vecToCenter=-force;
vecToCenter.normalize();
ForceToApply = vecToCenter * (force * vecToCenter);
ApplyFractionalForce(ForceToApply,FrameDuration);
ApplyFractionalTorque(TorqueToApply,FrameDuration,RadialArmDistance);
}