Calculate how much to turn with x,y and facing radians
Hello everyone o/
I'm trying to get the amount of degrees I need to turn to face object B (x=60,y=42 on map) but theres always mismatches, and I'm not talking about degree normalization (mod 360 or if degree>0 degree - 360) but the calc by itself. When i'm facin the oposite side of the object B i wont get an 180 degree (getting 170) and when facing the object (perfect line of sigh, completely pointed and on sight) I got 350 degrees on howMuchTurn oO There's something wrong I failed to see or any lesson I forgot to learn? The code snippet is the folowing: Code:
SetMapToCurrentZone() HALP! xD |
If you're getting ±10°, it may be the principle in which your calculations are based on. The 0-100 range is a scale on width or height when in fact, the zone area hardly ever is perfectly square. You can either convert these to real system coordinates or multiply X and Y by the width and height of WorldMapButton respectively.
|
GetPlayerMapPosition returns a number between 0 and 1, so subtracting 60 and 42 from those values should be drastically throwing off your calculations.
|
Any clues how tomtom does the calculus so?
@semlar GetPlayerMapPosition? I forgot to put on the snippet, but i'm multiplying X and Y coords by 100. @SDPhanton So it's an scale problem? Based on semlar tip, do you see anything I can do to transform my X and Y in "real world" or plausible/usable arctangent parameters without any external lib or plugin (found only WorldMapButton as an addon)? |
Turning this into a function of its own, this should do the trick. WorldMapButton is a child of WorldMapFrame that the map and all objects are placed on. TomTom used to use the AstroLab library for real coordinates of the map edges, but they are now provided through GetCurrentMapZone(). There's some additional complexity to using these if you want to include distances, but as you aren't including that in your design, this is a more simple approach.
Lua Code:
|
Quote:
|
All times are GMT -6. The time now is 07:36 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI