Skip to main content
edited title
Link
user1430
user1430

Rotate can I rotate an object to Target witha target angle using Euler Angles?

edited tags
Link
sam hocevar
  • 23.9k
  • 2
  • 64
  • 95
edited title
Source Link
JPtheK9
  • 2k
  • 2
  • 14
  • 32

Rotational Rotate to Target with Euler Angles

How do I rotate an object from its current angle to the desired angle in increments on 1 axis?

What The problem is the wraparound at 360 degrees What I have so far (Note: pseudocode):

double MaxSpeed = 5;

double CurrentAngle = -170;
double DesiredAngle = 40;

double Distance = DesiredAngle - CurrentAngle; //How do I calculate this value considering angle wraparound?

CurrentAngle += Mathd.clamp(Distance, -MaxSpeed, MaxSpeed); //Caps the rotation speed

Rotational with Euler Angles

How do I rotate an object from its current angle to the desired angle in increments on 1 axis?

What I have so far (Note: pseudocode):

double MaxSpeed = 5;

double CurrentAngle = -170;
double DesiredAngle = 40;

double Distance = DesiredAngle - CurrentAngle; //How do I calculate this value considering angle wraparound?

CurrentAngle += Mathd.clamp(Distance, -MaxSpeed, MaxSpeed); //Caps the rotation speed

Rotate to Target with Euler Angles

How do I rotate an object from its current angle to the desired angle in increments on 1 axis? The problem is the wraparound at 360 degrees What I have so far (Note: pseudocode):

double MaxSpeed = 5;

double CurrentAngle = -170;
double DesiredAngle = 40;

double Distance = DesiredAngle - CurrentAngle; //How do I calculate this value considering angle wraparound?

CurrentAngle += Mathd.clamp(Distance, -MaxSpeed, MaxSpeed); //Caps the rotation speed

Source Link
JPtheK9
  • 2k
  • 2
  • 14
  • 32
Loading