tanzfisch wrote:What exactly is relativeAngle? And why was it called relativeAngleError before?
Is that the amount I turn the body arround dir?
There are mainly two use cases, think of a door hinge.
First case is: Door can rotate freely, but it's not allowed to go outside 0-90 degrees.
This is a hard limit.
- Code: Select all
if (doorAngle > PI*0.5)
{
NewtonUserJointAddAngularRow (joint, doorAngle-PI*0.5, &hingeAxis)
NewtonUserJointSetRowMinimumFriction (joint, -angularFriction);
NewtonUserJointSetRowMaximumFriction (joint, 0);
}
if (doorAngle < 0)
{
NewtonUserJointAddAngularRow (joint, 0-doorAngle, &hingeAxis)
NewtonUserJointSetRowMinimumFriction (joint, -0);
NewtonUserJointSetRowMaximumFriction (joint, angularFriction);
}
So in this case we give the angle error.
Also with Friction function we set the maximum force / torque the joint can use to keep the limit.
We set it zero for the other direction because the door should not get stuck at 90 degrees,
it should be free to rotate back until it hits the 0 degrees angle.
Warning: I may accidently did this the wrong way around, reversing signs and Min/Max functions is a matter of trial and error. But you get the point...
Second case is: It's a revolving door that should constantly rotate at a given angular velocity
This is a motor.
- Code: Select all
float targetAngularAcceleration = measure angular velocity error and convert to angular acceleration that should fixe this error in short time
NewtonUserJointAddAngularRow (joint, 0, &hingeAxis);
NewtonUserJointSetRowAcceleration (joint, targetAngularAcceleration);
NewtonUserJointSetRowMinimumFriction (joint, -maxMotorTorque);
NewtonUserJointSetRowMaximumFriction (joint, maxMotorTorque);
Here we don't want to change the angle immideately, thus zero.
Instead we want to change acceleration, and optionally clamp torque again to prevent a infinite strong motor (no one should get killed by this door).
The term "relativeAngle" makes more sense if it's a joint between two bodies,
which is not the case for the kinematic joint, which is between a single body and global space.