Results 1 to 5 of 5

Thread: how do I calculate correct angles to an object ?

  1. #1
    Guest

    how do I calculate correct angles to an object ?

    My problem is,
    I`ve got some hemispheres and in order to rotate them correct I need to calculate the x, y and z angle from my viewpoint to the object, so that I`m able to rotate the hemisphere according to these angles. I already know how to get the correct distance and the relative coordinates from viewp. to object, but if I rotate the sphere these angles should change. I know Ive got to use the modelview matrix, but not how.
    Thanks...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    112

    Re: how do I calculate correct angles to an object ?

    If I understand your problem correctly all that is needed is a little bit of trig. There may be a better way to do what you want but the following way should work.

    ASSUMING the camera is at the origin and
    x, y, and z are the distance to object in the respective direction

    theta.x = arctan(z/y)
    theta.y = arctan(z/x)
    theta.z = arctan(x/y)

    Hope that helps.

  3. #3

    Re: how do I calculate correct angles to an object ?

    hhmmmm, when i try to use the arctan() function, the compiler cant find it, and i cant find the funtion in any help files, what do i have to include to use that function?

  4. #4

    Re: how do I calculate correct angles to an object ?

    hhmmmm, when i try to use the arctan() function, the compiler cant find it, and i cant find the funtion in any help files, what do i have to include to use that function?

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: how do I calculate correct angles to an object ?

    you have to include math.h.

    but the syntax is atan. arctan is the french symbol.

Similar Threads

  1. Replies: 4
    Last Post: 12-06-2017, 09:29 AM
  2. Calculate object orientation from a quaternion
    By JohnnyDread in forum OpenGL: General
    Replies: 1
    Last Post: 02-06-2011, 11:15 PM
  3. object appears under certain angles
    By coda in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-15-2004, 06:00 AM
  4. how do I calculate correct angles to a stereo object ?
    By apit in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-13-2003, 08:13 AM
  5. How to calculate thickness of an object?
    By billy in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-16-2001, 08:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean