• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

AngleBetweenPoints Function Stops Working on Points that have a Height

Status
Not open for further replies.
Level 11
Joined
Jul 20, 2004
Messages
2,760
This works just fine for me.
JASS:
lv_p1 = Point(0.0,0.0);
lv_p2 = Point(2.5,5.0); 
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, FixedToText(AngleBetweenPoints(lv_p1,lv_p2), c_fixedPrecisionAny));
PointSetHeight(lv_p1, 3.14);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, FixedToText(AngleBetweenPoints(lv_p1,lv_p2), c_fixedPrecisionAny));
PointSetHeight(lv_p2, 7.12);
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, FixedToText(AngleBetweenPoints(lv_p1,lv_p2), c_fixedPrecisionAny));
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Do make sure that both points you are using exist. It is very easy to accidenly lose track of references so you end up comparing a point with null (which probably would yield this behaviour).

Additionally, the function mechanics might not consider the Z demention (only X/Y) so trying to compare the angle of 2 points which only have different Z positions may result in this behaviour.
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
It does work that way. This function places the two points in a polar coordinates system (radius and angle). The resulting system is in fact centered in the first point, and the function computes the angle coordinate of the second point (with the Z coordinates ignored upon the translation).

In 3D, the problem is obviously expanded to three dimensions - more specifically a spherical coordinate system (radius, elevation angle, and azimuth angle). Because of the two distinct angles, separate functions would be needed to compute their values, with the radius remaining the classical euclidean distance between the two (the Azimuth Angle is the same as the 2D angle).

The Wiki article on the subject is very neat, and offers much more information, including conversion formulas (just in case you need something like this for your 3D solution).
 
Status
Not open for further replies.
Top