Page 1 of 1
Help, please. Need to convert X,Y vectors into degrees
Posted: Mon Jul 10, 2006 11:18 pm
by Colmino
The particular stumbling block I'm encountering here is a lack of understanding of how MacroQuest handles calculations of asin / acos etc. The results I am getting from such calculations are often frustratingly inexplicable and not what I expect.
If somebody with the knowledge / experience would be so kind, all I am after is the correct Math.Calc that will convert vector variables "VY" and "VX" (whose values range from -1 (north & west) to +1 (south and east), and were acquired from coordinates Me.Y, Me.X and variables MobY and MobX) into angle variable "Angle", measured in degrees from 0 to 360, which can be used in the /face command.
I admit to considerable confusion when attempting to dissect the solutions witnessable in other scripts, in spite of adequate knowledge of the relevant math / trigonometry.
Posted: Tue Jul 11, 2006 2:12 am
by dont_know_at_all
${Target.HeadingTo}
Posted: Tue Jul 11, 2006 8:38 am
by Colmino
dont_know_at_all wrote:${Target.HeadingTo}
Yes, quite. Thanks for the suggestion.
Yet this doesn't right away seem to be the solution I'm after. I can't use a command which calculates a heading to a target, because I'm trying to do this without targeting anything. In fact, to elaborate further, I intend to combine two separate vectors - by
strong preference based on the direction they define in degrees - and it goes without saying that ping-ponging targets won't be of much use.
Posted: Tue Jul 11, 2006 9:39 am
by fearless
${Spawn[${Spawn[a moss snake].ID}].HeadingTo}
or something like that
Posted: Tue Jul 11, 2006 12:49 pm
by blueninja
Yes let's use two spawn constructors when we only need one ;) ..
${Spawn[a moss snake].HeadingTo}
Besides what are you doing with acos and asin? atan is what you want for this calculation if I haven't forgotten everything about trigonometry.
Posted: Tue Jul 18, 2006 12:29 pm
by jimbo123
Atan will not help without the use of some other overly-complex logic, since it only returns values between -90 deg and +90 deg. Here is a thread in which the solution is discussed recently:
http://macroquest2.com/phpBB2/viewtopic.php?t=13393
Read the first post in the thread for the complex solution AND for povery's suggestion in that first post. Then check out povery's follow-up later. Then the easy solution will come to you.
If you don't have VIP access to read that link, do a search in the manual and study up on everything related to the following:
Spawn
HeadingToLoc
HeadingTo
You don't have to target anything, and as long as there is a spawn at one end of your vector it is very easy.
Caveat 1) EQ uses a retarder coordinate system. This becomes irrelevant if you do this the easy way, or all-important if you do it the hard way.
Caveat 2) /face faces the wrong direction. Reverse the sign of the (clockwise from North) heading you get from ...Heading.Degrees, in order to have the (CCW from North) heading that you need to feed to /face.
--jimbo