? (!Like trig): Goto "hereendeththelesson"
The following creates the absolute grid coordinates of a point from polar coordinates (distance + angle) relative to the position and direction of the origin object. It is, of course, related to THobson's:
X coordinate = x1 + d*sin(theta)
y coordinate = y1 + d*cos(theta)
but does away with the need to think about and change the formulae for the different directions. The trick is to add the target's direction to the origin's heading, so our formulae become:
x coordinate = x1 + d*sin(omega + theta)
y coordinate = y1 + d*cos(omega + theta)
Where omega can be considered the origin's facing and theta the relative direction of the target position. Logically, if I'm facing East (+90 degrees) and want an object on my left (+270 degrees from MY heading), the target object wants to be North of my position (360 = 90 + 270):
#hereendeththelesson
For trigonometrophobes, here's the script form:
_targetx = (GetPos _origin) Select 0 + (_distance * Sin (GetDir _origin + _reldir))
_targety = (GetPos _origin) Select 1 + (_distance * Cos (GetDir _origin + _reldir))
_targetpos = [_targetx,_targety,0]
_origin = your starting unit/object
_distance = the distance to the target position
_reldir = the relative direction of target position in degrees FROM THE DIRECTION _origin IS FACING, e.g.
Front: _reldir = 0
Right: _reldir = 90
Rear: _reldir = 180
Left: _reldir = 270
Half right: _reldir = 45
. . . and so on.