Currently, I am creating a simplified reaction control system for playing in the satellite and I need a way to use the system to coordinate the satellite with a given unit direction in the coordinates of world space. Since this is a game simulation, I fake the system and just apply the force of torque around the epicenter of objects.
This is difficult, because in my case the torque cannot be changed in strength, it is either on or off. This is either full power or no power. Calculation of the direction in which the torque should be applied is relatively simple, but I have problems aligning it without pushing out of control and getting stuck in a logical cycle. he needs to use the opposite force at exactly the right time to land on the target orientation at zero angular speed.
What I have determined so far is that I need to calculate the “time” it takes to reach zero speed based on my current angular speed and the angle between the two vectors. If this exceeds the time until it reaches the zero angle, then it needs to apply the opposite torque. Theoretically, this will also prevent too much "bounce" around the axis. I almost work, but in some cases it seems that he is stuck, using force in one direction, so I hope someone can check the logic. My simulation currently does not take mass into account, so you can ignore the inertia tensor (unless that makes the calculation easier!)
For one axis , I am doing it this way now, but I believe that someone will have a much more elegant solution that can actually calculate the Yaw and Pitch axes right away (Roll is not valid).
Omega = Angular Velocity in Local-Space (Degrees Per Second)
Force = Strength of the Thrusters
float Angle = AcosD(DotProduct(ForwardVector, DirectionVector));
float Time1 = Abs(Angle / Omega.Z);
float Time2 = Abs(DeltaTime * (Omega.Z / Force);
float AngleSign = Sign(DotProduct(RightVector, DirectionVector));
float Torque.Z = 0;
if (Time1 < Time2)
{
Torque.Z = AngleSign * Force;
}
else
{
Torque.Z = AngleSign * Force * -1.0f
}
This is far from elegant, and there are certain problems with the symptoms. Do you know what is the best way to achieve this?
EDIT: If someone understands the Unreal Engine Blueprint system, here's how I prototype it now before moving it to C ++

source
share