Thread: acosf not working?

  1. #1
    Banned
    Join Date
    Jan 2003
    Posts
    1,708

    acosf not working?

    I am trying to determine the number of degrees between two vectors. Here is a list of the cosine values, but acosf does not seem to be producing the correct values for the given cosine...WEIRD


    cosine: 0.718 degrees: 0.769871
    cosine: 0.807239 degrees: 0.631337
    cosine: -0.23837 degrees: 1.81148
    cosine: 0.424929 degrees: 1.13191
    cosine: 0.00990651 degrees: 1.56089
    cosine: -0.177051 degrees: 1.74879
    cosine: 0.157448 degrees: 1.41269
    cosine: 0.745396 degrees: 0.729667
    cosine: 0.839322 degrees: 0.574762
    and here is the code:

    Code:
    Vector	ObjectToCamera = Position - Player1->CamPos;
    float	CosTheta = DotProduct(Player1->View, ObjectToCamera) / (Player1->View.GetLength() * ObjectToCamera.GetLength());
    float	Degrees = acosf(CosTheta);

  2. #2
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    seriously this is weird, it works fine when I test for just the cosine equivalent for 45 degrees (less than .70710)

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    your code works fine, the answers you get are in radians

  4. #4
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I thought acosf only returned answers in degrees...
    EDIT:
    I just looked on MSDN, you're right, it returns the anwer in Radians, I assumed wrong. Thx Perspective

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    no prob!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM