Results 1 to 7 of 7

Thread: X or Y Axis coordinates from degrees

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default X or Y Axis coordinates from degrees

    Is it possible to get the x and y coordinates for an item from the degrees and distance you are from an object.

    If we think of a circle and I am the middle point of that circle and I can get the distance from an object and also the angle from me to the object, it should be theoretical possible to get the Y or X axis coordinates of the object.

    I don't have the math for this, can some one help me with that? Is it possible to do something like this?

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Read wrong
    Last edited by masterBB; 09-11-2012 at 09:00 PM.
    Working on: Tithe Farmer

  3. #3
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    RotatePoint.

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    not tested

    Simba Code:
    var
      angle, dist: Extended;
    begin
      angle := 210 / 180 * PI; //degrees to radians
      dist := 20;

      x := Sin(Angle) * dist;
      y := Cos(Angle) * dist * -1;
    end;
    Working on: Tithe Farmer

  5. #5
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I'm honestly a bit confused here; how are you relating items to objects? Are you trying to get a tile X/Y coordinate of an object on the MS? If you give me an example I could surely understand you better.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  6. #6
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I'm honestly a bit confused here; how are you relating items to objects? Are you trying to get a tile X/Y coordinate of an object on the MS? If you give me an example I could surely understand you better.
    Sorry that I only reply now but I was a bit peckered and went to sleep.

    Yes, it is a object on the main screen, I identify it correctly and I move to the object, but in between me and the object is a lot of opsticals around which I have to move, so what I want is the coordinates of the x or y axis so that I can work out where I can draw a box which will tell me when the object was removed and it must be accurate in doing that. I know the distance to the object, I know the degrees from me to the object, how do I take that two values and convert it to a coordinate where I can draw the box? I will not always end up precisely N,E,S,W off the object, it might not always be one object that is different from all the other objects, there might be 4 or 5 close to that one, that one was just the closest from the mscx, mscy when I did the search.

    Hope this clarifies it more.

    @ masterBB, I will be testing your code later on and let you know what I find. Thanks


  7. #7
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    masterBB's code will work. The angle in his code refers to the angle between the line and the normal (the upper vertical line). Basic trigonometry if you can see the right angle triangle. You'll have to add/subtract the x,y value from his code to MSCX,MSCY too in order to get the actual coordinate.

    And just in case your compass is not facing perfectly north, you can use rs_GetCompassAngleRadians then RotatePoint.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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