#### Archived

This topic is now archived and is closed to further replies.

# simple vector camera rotation

This topic is 5466 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''ve been having some trouble rotating my camera. It is defined by four vectors (position, up, forward, and right; where up, forward, and right are relative to position). I want to be able to modify the camera''s yaw, pitch, and roll. I initially wanted to simply pass an angle into a function and create a transformation matrix based on this angle, but I couldn''t get this to work at all (for not enough understanding/practice in matrix math). Next I tried to also store 3 floats - r, p, and y (for roll, pitch, yaw). Then I update my three vectors based on trig of a unit circle. Thus:
float Camera:itch(float angle) {
p+=angle;
update(); }
float Camera::yaw...
float Camera::roll...
float Camera::update() {
forward.x = cos(y);
forward.y = sin(p);
forward.z = sin(y);
right.x = cos(p+pi/2);
right.y = sin(r);
right.z = sin(p+pi/2);
up=CrossProduct(forward, right); } 
This code goes haywire - the vectors arent calculated correctly. What am I doing wrong - or, could I have a few tips on the first method? -- Dustin

1. 1
2. 2
JoeJ
20
3. 3
4. 4
5. 5
frob
13

• 9
• 10
• 13
• 9
• 23
• ### Forum Statistics

• Total Topics
632195
• Total Posts
3004712

×