Jump to content

  • Log In with Google      Sign In   
  • Create Account


Strafing left and right


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Hector   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 November 1999 - 12:59 AM

What is the formula to strafe left or right?
In the following code fragment, FORWARD and BACKWARD work perfectly but LEFT and RIGHT only work properly when the angle is 0, PI/2, PI, 3PI/2 or 2PI. Another thing I noticed is that when the angle is PI/4, 3PI/4, 5PI/4 or 7PI/4 and I hold down FORWARD and LEFT or BACK and RIGHT the camera strafes left and right properly. I am useing a fixed cordinate system with the camera moving parallel to the x and z plane.

switch (key)
{
< >case FORWARD:
< >cameraz -= cos(angle);
< >camerax += sin(angle);
< >glutPostRedisplay();
< >break;
< >case BACK:
< >cameraz += cos(angle);
< >camerax -= sin(angle);
< >glutPostRedisplay();
< >break;
< >case LEFT:
< >cameraz += sin(angle);
< >camerax -= cos(angle);
< >glutPostRedisplay();
< >break;
< >case RIGHT:
< >cameraz -= sin(angle);
< >camerax += cos(angle);
< >glutPostRedisplay();
< >break;
< >default:
< >break;
}


Sponsor:

#2 MikeD   Members   -  Reputation: 158

Like
Likes
Like

Posted 08 November 1999 - 12:59 AM

What happens when it is not working properly?
In which direction does it go?





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS