Advertisement

Need a tad bit off help rotating... :(

Started by August 01, 2002 02:49 AM
3 comments, last by Big Boy Rees 22 years, 6 months ago
Hey there... I just kinda need a bit off help (as in I have no idea) with rotating the location of the focus point around the eye point. I thought that maybe I could use cos and sin but all my attempts with that failed. (yes, Im not the smartest of programmers) What I have is the focus z and x are always + 10 from the eye z and x. The focus y is always the eye y value. I thought maybe I could use some radian stuff (which I did last term in school) and realised I have no idea how to implent that into vb. If anyone can help me, please dont give me a massive code sample... just point me in the right direction.. as in "What you need to do is use the radius of your intended circle multiplied by cos by the angle." -thanx. yes, yes I am stupid.
yes, yes I am stupid.
Everytime i need to use Cos/sin a always have this in mind:

cos(0) = 1
sin(0) = 0

cos(90) = 0
sin(90) = 1

and also if the angle is less then 0 like sin(-90) = -1

what you use for a simple rotation is
x = radius * sin(angle)
and
z = radius * cos(angle)

so:

x = 10 * sin(Angle);


as you see if angle = 0 x = 0 like it should if you want 0 degrees rotation to be a possition facing inwards.

and:

z = -10 * cos(Angle);

if angle = 0 (Cos(0) = 1) z = -10

so at start our viewpoint is facing in to the screen (0, 0, -10)

if you then starts to rotate increasing the angle we want to rotate that point to the right so if we have rotated 10 degress

x = 10 * sin(10);
x = 10 * 0.173; (Sin(10) = 0.17xxx)
x = 1.73


and:

z = -10 * cos(10);
z = -10 * 0.98;
z = -9.8;

as you can see our x increases (until we reach 90 degrees) and z will decrease.






fatal error C1004: unexpected end of file found
Swedish: #Gamedev.se on EFNET
Advertisement
Hey thanx a bunch! Ive read through what you''ve said and copied a bit of code from another thread so I will try these out..

Maybe soon I will get to collision detection! :S

yes, yes I am stupid.
yes, yes I am stupid.
sin, cos take their angles in radians not degrees...
So sin(10) is not the sine of 10 degrees.
360 degrees = 2*PI radians
so radians = degrees*(2*PI)/360

You are a normally better using radians throughout to avoid conversions at run time.
Thanx for the type but I spend 3 hours working that out just before.. :S

Anyways now I''m up to the problem of pressing up in my first person game, and getting the eye and focus point to move along the vector path.

What I tried was (in visual basic)

*************
TriHyp = (Sqr(m_vFocusPt.x ^ 2 + m_vFocusPt.z ^ 2)) + MovementRate
m_vFocusPt.x = TriHyp * Sin(CamTheta)
m_vFocusPt.z = TriHyp * Cos(CamTheta)

TriHypEye = (Sqr(m_vEyePt.x ^ 2 + m_vEyePt.z ^ 2)) + MovementRate
m_vEyePt.x = TriHypEye * Sin(CamTheta)
m_vEyePt.z = TriHypEye * Cos(CamTheta)
**************

Whereas camtheta was the amount of turning. (in degrees which I have run through a converter.)

I tried also working out the TriHypeEye by subtracting the distance between the eyes x,z co-ords from the TriHyp value, but still got the same results.

One day I may get to collision detection...

yes, yes I am stupid.
yes, yes I am stupid.

This topic is closed to new replies.

Advertisement