Results 1 to 3 of 3

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

  1. #1
    Join Date
    Mar 2011
    Location
    N 11░ 19' 0.0012 E 142░ 15' 0
    Posts
    1,519
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    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
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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
    Location
    SE PA USA
    Posts
    28,951
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    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, 05:12 AM
  2. Run into a conflict in CSS - degrees
    By lilpete in forum CSS
    Replies: 0
    Last Post: 01-25-2011, 11:38 AM
  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, 01:29 PM
  5. get coordinates of <div> tag
    By suman in forum JavaScript
    Replies: 1
    Last Post: 11-20-2006, 06:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •