Results 1 to 3 of 3

Thread: Using math.h in OpenGL

  1. #1
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    Using math.h in OpenGL

    Ok, the opposite and adjacent sides of a right triangle i have drawn are 1. I want to use tan to find one of the angles. It never works. I have tried tana() and tanh() and they dont work either. I know the answer should be 45 degrees, what is wrong?

    Tana() sounds like it is what I want. I call tanaf(1.0f) but it always returns 0.76 when it should be 45!

    What is wrong?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Huntsville, AL. USA
    Posts
    302

    Re: Using math.h in OpenGL

    The arc-tangent of 1.0 is 0.76 radians which is 45 degrees.

    do this ...

    static double R2D = 180.0/3.141592654;
    double myAngleInRadians = atanf(1.0);
    double myAngleInDegrees = myAngleInRadians*R2D;

    The standard match libraries work with angles in radians. Note however that OpenGL works with angles in degrees.

    Good luck
    Obsessive - A word used by the lazy to describe the motivated.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    Re: Using math.h in OpenGL

    thanks

Similar Threads

  1. math training for opengl
    By giugio in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-29-2012, 04:18 AM
  2. math and openGL
    By mikau in forum OpenGL: General
    Replies: 10
    Last Post: 08-13-2005, 09:07 AM
  3. OpenGL + Math Book
    By mark_key in forum OpenGL: General
    Replies: 7
    Last Post: 11-03-2004, 02:17 PM
  4. Help Me out with Math for OpenGL - I'm 14!
    By 31337 in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 05-30-2002, 08:33 PM
  5. OpenGL and Math
    By willdog23 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-19-2001, 08:04 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