Thread: Inverse Tangent

  1. #31
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    @ Quantrizi:
    >>Hunter: Thanks. Polar coordinates use (radius, theta) though.
    Isn't that what I said?

    Well, first of all, your checking if x != 0 (the if(x < 0 || x > 0) statement) comes after the 'y / x' operation is done... so if x == 0, then you'll already have a division by zero error anyways.

    I'm not totally sure what you're doing with the angle checking, because atan() will only ever return from -90 to +90. Your checks for theta > 90 etc. will never get run. Actually, I don't think there's any way to get the angle in the proper quadrant without looking at the original x and y coordinates (i.e. as in my post, or Thantos' post, or Micko's).

    @ Micko:
    You should consider revising your method. The deeply nested if's and else's make the code hard to read (and unintuitive), especially without the opening/closing braces to mark where each if/else begins and ends.

    **EDIT**
    Code:
    if(x < 0 && y > 0)
    	theta = 180 - theta;
    Does this work? In this case theta < 0, so (180 - theta) > 180, which is in quadrant 3 or 4. But, if x < 0 and y > 0, clearly the angle is supposed to be in quadrant 2 instead.
    Last edited by Hunter2; 05-09-2004 at 04:59 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #32
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Quote Originally Posted by Hunter2
    @ Quantrizi:
    >>Hunter: Thanks. Polar coordinates use (radius, theta) though.
    Isn't that what I said?

    Well, first of all, your checking if x != 0 (the if(x < 0 || x > 0) statement) comes after the 'y / x' operation is done... so if x == 0, then you'll already have a division by zero error anyways.

    I'm not totally sure what you're doing with the angle checking, because atan() will only ever return from -90 to +90. Your checks for theta > 90 etc. will never get run. Actually, I don't think there's any way to get the angle in the proper quadrant without looking at the original x and y coordinates (i.e. as in my post, or Thantos' post, or Micko's).

    @ Micko:
    You should consider revising your method. The deeply nested if's and else's make the code hard to read (and unintuitive), especially without the opening/closing braces to mark where each if/else begins and ends.
    Ok, thanks

    I got the code to work though, w/ Micko's code. I made it more neat, for the reasons Hunter2 said it was bad (the nesting).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to inverse a trig?
    By Diablo02 in forum C# Programming
    Replies: 4
    Last Post: 11-07-2007, 10:11 PM
  2. Multiplying tangent and bitangent by scale matrix
    By psychopath in forum Game Programming
    Replies: 6
    Last Post: 02-08-2006, 08:28 AM
  3. ROW OPERATIONS (finding Inverse) (im going crazy)
    By alexpos in forum C Programming
    Replies: 1
    Last Post: 11-20-2005, 10:07 AM
  4. inverse matrix
    By Yumin in forum C++ Programming
    Replies: 2
    Last Post: 11-15-2005, 12:06 AM
  5. Calculating inverse tangent
    By bludstayne in forum Tech Board
    Replies: 12
    Last Post: 02-27-2004, 12:59 PM