# Calculating Rotation For X,Y !!! URGENT !!!

I am working on a program that takes two coords from a 3D game (X and Y, Z not relevent), and calculates how far point A (current position) is from point B (target position). However, i am having problems calculating which direction the object on point A needs to be facing (in degrees) to get to point B. I know there is some formula for this, however, I'm clueless.

So lets say my current position in the game is X-996 and Y-1071 currently facing a value of 100 (from what i see rotation is measured on a -180 to 180 scale, north being -90, east being 180, south being 90 and west being 0) and my target location is X-985 Y-1133, how would i go about calculating the rotation at which i need to be facing in order to reach my target position?

Below is the function i am currently using (programmed in autoit), that doesnt seem to work. what it does is grabs the coords from the objects current position then reads &quot;waypoints&quot; or pre-defined target positions from the text file. after that it tries to calculate the rotation (which is wrong) and then moves in that position towards the target position.

---------------------------------------------------------------------------------

Func _Turn()

Local \$Cur_Coords = _GetCoords()

Local \$Next_Coords = StringSplit(FileReadLine(@ScriptDir &amp; &quot;\waypoints.txt&quot;,\$Cur_Waypoint), &quot;,&quot;) ;split x, y, z, map

;-------------------------------------------

Local \$PosX = \$Cur_Coords[0]-\$Next_Coords[1];x

Local \$PosY = \$Cur_Coords[1]-\$Next_Coords[2];y

\$Next_Rot = _ATan2(\$Next_Coords[2] - \$Cur_Coords[1], \$Next_Coords[1] - \$Cur_Coords[0]) * 180 / \$Pi

GUICtrlSetData(\$Input6, \$Next_Coords[1])

GUICtrlSetData(\$Input7, \$Next_Coords[2])

GUICtrlSetData(\$Input10, Floor(\$Next_Rot))

\$Cur_Rot = _GetRotation()

If \$Next_Rot = \$Cur_Rot Then Return \$Next_Rot

While \$Cur_Rot &lt;&gt; \$Next_Rot And \$Run

\$Cur_Rot = _GetRotation()

_MouseMovePlus()

GUICtrlSetData(\$Input5, Floor(\$Cur_Rot))

WEnd

Return \$Next_Rot

EndFunc

---------------------------------------------------------------------------------

Now this shouldnt be too hard of a project, its a matter of doing mabye 1 or 2 calculations, so my budget limit is 50\$ (i doubt it would take more then 10 minutes to figure out if your good at things like this) so bid accordingly

I NEED THIS DONE ASAP! SOONER THE BETTER!

( 0 reviews ) Grand, United States

Projektin tunnus: #512132

## 17 freelanceria on tarjonnut keskimäärin 47 \$ tähän työhön

dimic

31 \$ USD 1 päivässä
(4 arvostelua)
2.5
teteam

150 \$ USD 4 päivässä
(0 arvostelua)
0.0
SomendraIndia

I can finish this in within a day. And I'm charging my minimum fare of 75\$ for this project.

75 \$ USD 0 päivässä
(0 arvostelua)
0.0
gabi44

I worked with graphics processing and this can be done easily. Tell me the language you want to be used.

30 \$ USD 1 päivässä
(0 arvostelua)
0.0
VuVirt

30 \$ USD 0 päivässä
(0 arvostelua)
0.0
yates

Simple. I have a BA in Mathematics, a BS in Electrical Engineering, and graduate coursework as well. I can do this quickly and easily for you.

30 \$ USD 1 päivässä
(0 arvostelua)
0.0
CamiloNino

Hi Im a professional Electronics Engineer. I have done some simulation projects in c/c++ and in Matlab that solves this problem, i can give the solution to you in no time and if you want some advice on the rest of t Lisää

30 \$ USD 1 päivässä
(0 arvostelua)
0.0
bungy

Solved. Your calculations are OK but you have to use \$Next_Coords[0] and \$Next_Coords[1] instead \$Next_Coords[1] and \$Next_Coords[2], so, send me my 25\$. Thanks. There is no _ATan2 function in autoit(chm help). I hope Lisää

30 \$ USD 0 päivässä
(0 arvostelua)
0.0
AmbienceStudio

Hello, Nodon. I've sent the right formula to you in PM. Pls, check it.

30 \$ USD 1 päivässä
(0 arvostelua)
0.0
romelvb

Its a simple project

35 \$ USD 1 päivässä
(0 arvostelua)
0.0
cdahlquistjr

I already have it worked out. Bid is at minimum, would have bed less.

30 \$ USD 1 päivässä
(0 arvostelua)
3.0
lyjbupt

40 \$ USD 0 päivässä
(0 arvostelua)
0.0
FallWind

30 \$ USD 0 päivässä
(0 arvostelua)
0.0
VPopescu

Your problem is very simple. You should use a rotation matrix.

110 \$ USD 2 päivässä
(0 arvostelua)
0.0
vasanth204

30 \$ USD 3 päivässä
(0 arvostelua)
2.8
rahul4310

Hi, I am a graduate with B-tech degree in computer science. I am currently doing my MS by research in computer graphics. This problem is actually a toy problem for me and I can easily do it. I am expert in c/c++ , ma Lisää

30 \$ USD 1 päivässä
(0 arvostelua)
0.0
makarsky

It is a simple geometric calculation, i have prepared solution within last 10 minutes. My bid is at project minimum bid.

30 \$ USD 0 päivässä
(0 arvostelua)
0.0
nilanjan22

I want to bid for \$50 and the project can be delivered in 2 days time.

50 \$ USD 2 päivässä
(0 arvostelua)
0.0