Results 1 to 3 of 3

Thread: Maths -> Convert Degrees to X/Y Coordinates

  1. #1
    Join Date
    Mar 2011
    Thanked 121 Times in 117 Posts
    Blog Entries

    Default Maths -> Convert Degrees to X/Y Coordinates

    Hey all,
    I'm having a lot of trouble with a little project I'm working on.
    I'd like to choose a compass bearing (0 - 360) and then move an object in that direction (using X and Y coordinates).

    For the first quadrant, I just use trig (tan) to calculate it. But in all the other ones I'm having weird issues. (Tan is the best option because you can calculate the gradient but tan is only positive in two quadrants)
    Any tips to point me in the right direction?

  2. #2
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    I can't quite picture what you have designed (but I have a fairly good idea), so I'll just answer in general terms.

    You've got the (relatively) difficult trig part done. Now you just need to figure out the sign. An easy way to deal with this is to divide the circle into quadrants and work from there-- adjust the sign as needed, and subtract in increments of 90 degrees.

    Technically you can probably do this without that and still get the right numbers using tan, but I'm not sure.

    Remember the Pythagorean theorem as well, which might help for figuring out X and Y.

    Basically just do some trial and error until the signs work out, then the rest should fit into place.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries


    I assume you've tried cotangent, secant?
    - John

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Resolved Javascript maths
    By keyboard in forum JavaScript
    Replies: 5
    Last Post: 02-04-2012, 06:12 AM
  2. Run into a conflict in CSS - degrees
    By lilpete in forum CSS
    Replies: 0
    Last Post: 01-25-2011, 12:38 PM
  3. Replies: 1
    Last Post: 10-18-2009, 05:47 PM
  4. Bodmas Maths Equation Generation...
    By clowes in forum PHP
    Replies: 7
    Last Post: 03-04-2009, 02:29 PM
  5. get coordinates of <div> tag
    By suman in forum JavaScript
    Replies: 1
    Last Post: 11-20-2006, 07:22 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