how to convert ( 0, 0 , 1 ) to degrees plz

how to convert ( 0, 0 , 1 ) to degrees plz

Post by John » Mon, 08 Apr 2002 04:57:09



can anyone please tell me how can u convert the view
matrixs LOOK AT vector to degrees?

like when ( its pointing at ( 0.5, 0.5, 0.5 ) u knw its
45 degrees but how do u mathematically convert the 0.5 to
45 degrees

thanks a lot

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Rich [Microsoft Direct3D MV » Mon, 08 Apr 2002 05:20:59


[Please do not mail me a copy of your followup]



Quote:>like when ( its pointing at ( 0.5, 0.5, 0.5 ) u knw its
>45 degrees but how do u mathematically convert the 0.5 to
>45 degrees

Are you familiar with trigonometry?
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    izfree: Open source tools for Windows Installer
            http://izfree.sourceforge.net

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by John » Mon, 08 Apr 2002 06:20:33


yes i am

just let me know the concept or whatever that can lead
somewhere

i used to know how u could do it but now i forgot ....

>-----Original Message-----
>[Please do not mail me a copy of your followup]



>>like when ( its pointing at ( 0.5, 0.5, 0.5 ) u knw its
>>45 degrees but how do u mathematically convert the 0.5
to
>>45 degrees

>Are you familiar with trigonometry?
>--
>Ask me about my upcoming book on Direct3D from Addison-
Wesley!
>  Direct3D Book http://www.xmission.com/~legalize/book/
>    izfree: Open source tools for Windows Installer
>            http://izfree.sourceforge.net
>.

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Rich [Microsoft Direct3D MV » Mon, 08 Apr 2002 07:13:20


[Please do not mail me a copy of your followup]



Quote:>>Are you familiar with trigonometry?

>yes i am

Great, that will make things easier.  The identities you need are for
converting from polar coordinates to rectangular coordinates.

If you have a 2D point with cartesian coordinates <x,y>, then you
can convert the point to polar coordinates with a magnitude r and
angle theta with respect to the x axis:

    r = sqrt(x*x + y*y)
    theta = atan2(y, x)

    ^ y
    |     + (x,y)
    |    /
    | r /
    |  /
    | /
    |/ theta
    +--------------> x

(You can also use the function atan(y/x), but atan2() handles the
signs properly to give the proper quadrant.)

To go from polar to rectangular coordinates:

    x = r*cos(theta)
    y = r*sin(theta)

(With a little algebraic manipulation and the identities:
    tan(theta) = sin(theta)/cos(theta)
    cos(theta)*cos(theta) + sin(theta)*sin(theta) = 1
you can solve backwards for r and theta given x and y.)

Things are similar for 3D points, except that now you have a
magnitude r and two angles theta and phi, where theta and phi are
angles with respect to two of the principal axes, usually the angle
of the point when projected into the xy and xz planes.

This discussion computes the angle of a point with respect to the
origin.  To find the relative angle between two points you can
apply a translation to make one of the points coincident to the
origin and use the same logic.

With vectors, we have dot and cross product operations that can also
be useful for computing angles.

For two vectors a and b,

    a dot b = length(a)*length(b)*cos(theta)

where theta is the smallest angle between the two vectors.  This
works for 2-d and 3-d vectors.

    length(a cross b) = length(a)*length(b)*sin(theta)

and again, theta is the smallest angle between the two vectors.

D3DX provides 2D and 3D vector classes with functions for dot and
cross products.
--
Ask me about my upcoming book on Direct3D from Addison-Wesley!
  Direct3D Book http://www.xmission.com/~legalize/book/
    izfree: Open source tools for Windows Installer
            http://izfree.sourceforge.net

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Trenche » Mon, 08 Apr 2002 07:16:28


Rich,

Forgive me for my last post, I was totally wrong about you!!! SORRY!

T.



> [Please do not mail me a copy of your followup]



> >>Are you familiar with trigonometry?

> >yes i am

> Great, that will make things easier.  The identities you need are for
> converting from polar coordinates to rectangular coordinates.

> If you have a 2D point with cartesian coordinates <x,y>, then you
> can convert the point to polar coordinates with a magnitude r and
> angle theta with respect to the x axis:

>     r = sqrt(x*x + y*y)
>     theta = atan2(y, x)

>     ^ y
>     |     + (x,y)
>     |    /
>     | r /
>     |  /
>     | /
>     |/ theta
>     +--------------> x

> (You can also use the function atan(y/x), but atan2() handles the
> signs properly to give the proper quadrant.)

> To go from polar to rectangular coordinates:

>     x = r*cos(theta)
>     y = r*sin(theta)

> (With a little algebraic manipulation and the identities:
>     tan(theta) = sin(theta)/cos(theta)
>     cos(theta)*cos(theta) + sin(theta)*sin(theta) = 1
> you can solve backwards for r and theta given x and y.)

> Things are similar for 3D points, except that now you have a
> magnitude r and two angles theta and phi, where theta and phi are
> angles with respect to two of the principal axes, usually the angle
> of the point when projected into the xy and xz planes.

> This discussion computes the angle of a point with respect to the
> origin.  To find the relative angle between two points you can
> apply a translation to make one of the points coincident to the
> origin and use the same logic.

> With vectors, we have dot and cross product operations that can also
> be useful for computing angles.

> For two vectors a and b,

>     a dot b = length(a)*length(b)*cos(theta)

> where theta is the smallest angle between the two vectors.  This
> works for 2-d and 3-d vectors.

>     length(a cross b) = length(a)*length(b)*sin(theta)

> and again, theta is the smallest angle between the two vectors.

> D3DX provides 2D and 3D vector classes with functions for dot and
> cross products.
> --
> Ask me about my upcoming book on Direct3D from Addison-Wesley!
>   Direct3D Book http://www.xmission.com/~legalize/book/
>     izfree: Open source tools for Windows Installer
>             http://izfree.sourceforge.net

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Trenche » Mon, 08 Apr 2002 07:08:54


John,

You can forget getting any answer from the bozo who replied earlier. He's on
some kind of self-appointed pedestal. If you look, you'll notice he responds
to almost every post, but doesn't come close to actually answering the
question much solving the problem. So hopefully if you ignore him, he'll
just go away.

Now, let's see if I can help you with your problem....I can show you how to
go the other way, given latitude and longitude values you can convert those
to Eye, Up vectors for "look at" type things:

LAT & LON are always computed first by converting degrees to radians...

m_fLat = (ANGLE1 * (PI / 180));
m_fLong = (ANGLE2 * (PI / 180));

Now, given those two values you can compute the following:

     m_fEyeX = cos(m_fLat)*sin(m_fLong);
     m_fEyeY = sin(m_fLat);
     m_fEyeZ = cos(m_fLat)*cos(m_fLong);

     m_fUpX = -sin(m_fLat)*sin(m_fLong);
     m_fUpY = cos(m_fLat);
     m_fUpZ = -sin(m_fLat)*cos(m_fLong);

Given that you can now use Eye and Up for camera orientations...

LookAt( m_fEyeX, m_fEyeY, m_fEyeZ,
               0.0, 0.0, 0.0,
               m_fUpX, m_fUpY, m_fUpZ );

This will point your camera at the origin ( 0, 0, 0).

Note: You may also have to do some translating depending on where you want
to position your camera.

Hope this helps.

T.


> yes i am

> just let me know the concept or whatever that can lead
> somewhere

> i used to know how u could do it but now i forgot ....

> >-----Original Message-----
> >[Please do not mail me a copy of your followup]



> >>like when ( its pointing at ( 0.5, 0.5, 0.5 ) u knw its
> >>45 degrees but how do u mathematically convert the 0.5
> to
> >>45 degrees

> >Are you familiar with trigonometry?
> >--
> >Ask me about my upcoming book on Direct3D from Addison-
> Wesley!
> >  Direct3D Book http://www.xmission.com/~legalize/book/
> >    izfree: Open source tools for Windows Installer
> >            http://izfree.sourceforge.net
> >.

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Cronus3 » Mon, 08 Apr 2002 07:31:07


Quote:> John,

> You can forget getting any answer from the bozo who replied earlier. He's
on
> some kind of self-appointed pedestal. If you look, you'll notice he
responds
> to almost every post, but doesn't come close to actually answering the
> question much solving the problem.

Considering Rich is probably the most useful person on this board...although
he won't hold your hand or think for you.

The original post is off topic anyways.  Try a math newsgropu or
comp.graphics.algorithms.

 
 
 

how to convert ( 0, 0 , 1 ) to degrees plz

Post by Eric DeBrosse [MS MVP » Mon, 08 Apr 2002 07:45:36


Quote:> Considering Rich is probably the most useful person on this
board...although
> he won't hold your hand or think for you.

Right on, couldn't have said it better myself!

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.

 
 
 

1. plz plz plz plz HELP

any of you guys able to successfully import a model from poser to lightwave
and then add bones to it??(yeah-i know....using poser.....im just too lazy)
any help would be appreciated
Ash
=============<^>=============

2. FS: VideoFramer

3. Plz help how to convert RGB to HVC

4. Blue NOise Mask Error Diffusion Techniques

5. convert problem! plz help

6. YAODL --- help!

7. Converting Degrees to radians? HELP Please

8. How to radially stretch a span of 120 degrees by another 5 degrees

9. Change degree 3 curve to degree 1 curve