[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/20/2009 at 06:39AM PDT, ID: 24746602
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Help Calculating Rotation (Autoit)

Asked by nod43 in Algorithms, 3D Game Programming, Physics & Artificial Intelligence in Game Programming

Tags: Auto It, XYZ, Calculate, Rotation, Trig, ATan, ATan2

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, that doesnt seem to work. what it does is grabs the coords from the objects current position then reads "waypoints" 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.

any help much appreciated ^_^
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Func _Turn()
    Local $Cur_Coords = _GetCoords()
    Local $Next_Coords = StringSplit(FileReadLine(@ScriptDir & "\waypoints.txt",$Cur_Waypoint), ",") ;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 <> $Next_Rot And $Run
		$Cur_Rot = _GetRotation()
		_MouseMovePlus()
		GUICtrlSetData($Input5, Floor($Cur_Rot))
	WEnd
 
    Return $Next_Rot
EndFunc
 
Keywords: Help Calculating Rotation (Autoit)
 
Loading Advertisement...
 
[+][-]09/21/09 12:51 AM, ID: 25380880

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Algorithms, 3D Game Programming, Physics & Artificial Intelligence in Game Programming
Tags: Auto It, XYZ, Calculate, Rotation, Trig, ATan, ATan2
Sign Up Now!
Solution Provided By: ikework
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09/21/09 04:05 PM, ID: 25388483

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11/12/09 04:55 PM, ID: 25810440

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625