Help, please. Need to convert X,Y vectors into degrees

Have a macro idea but not sure where to start? Ask here.

Moderator: MacroQuest Developers

Colmino
orc pawn
orc pawn
Posts: 10
Joined: Sat Jul 08, 2006 5:40 am

Help, please. Need to convert X,Y vectors into degrees

Post by Colmino » Mon Jul 10, 2006 11:18 pm

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.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Tue Jul 11, 2006 2:12 am

${Target.HeadingTo}

Colmino
orc pawn
orc pawn
Posts: 10
Joined: Sat Jul 08, 2006 5:40 am

Post by Colmino » Tue Jul 11, 2006 8:38 am

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.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Tue Jul 11, 2006 9:39 am

${Spawn[${Spawn[a moss snake].ID}].HeadingTo}

or something like that
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Tue Jul 11, 2006 12:49 pm

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.

jimbo123
a ghoul
a ghoul
Posts: 87
Joined: Wed Dec 21, 2005 9:46 pm

Post by jimbo123 » Tue Jul 18, 2006 12:29 pm

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