FANDOM


GetAngleBetweenLocations(location, location)

returns a float representing the angle between location one and location two.

float GetAngleBetweenLocations(
    location lOne,
    location lTwo
);

ParametersEdit

location lOne

  • Location One

location lTwo

  • Location Two

DescriptionEdit

This is a convenience function that returns a float representing the angle between lOne and lTwo. This is done by extracting the positions from lOne and lTwo, then getting the distance between the two locations. Then the absolute change in the x axis is calculated and the result is applied to acos(deltaX / distance). The result is a number who’s value represents the absolute bearing (where North=0) between the two locations.

CallsEdit

int abs(int iNum)
float acos(float fNum)
int FloatToInt(float fNum)
float IntToFloat(int iNum) 
vector GetPositionFromLocation(location loc) 
float GetDistanceBetweenLocations(location lone, location lTwo)

RemarksEdit

This method may suffer from round-off error, in the line:

IntToFloat(abs(FloatToInt(vPos1.x - vPos2.x)))  

When vPos2.x is subtracted from vPos1.x and there is no guarantee that (vPos1.x > vPos2.x) is true. This author has to wonder about the absence of a fAbs function that returns the absolute value of a float, baring that why not simply write the following check:

float fChangeX = vPos1.x – vPos2.x; 
if (fChangeX < 0) 
fChangeX = -fChangeX; 

as was done in GetChangedPosition. But this is merely this writer’s opinion; the precision error however can be real.

Also remember, this requires the include file x0_i0_position.

RequirementsEdit

#include"x0_i0_position"

VersionEdit

1.61

See AlsoEdit

Functions:

abs | acos | FloatToInt | GetDistanceBetweenLocations | GetPositionFromLocation | IntToFloat

Converted from NWNLexicon

author: Michael Nork, editor: Jasperre, additional contributor(s): James E. King

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.