Introduction
We know the absolute direction, the relative direction and the whole direction system of Robocode in the front. I believe you have a deep understanding of this. But the problem came again, knowing that the direction did not seem to fully achieve the purpose of understanding the enemy. How to detect the enemy's distance? How exactly do you lock your target? What do we do with moving targets? Here we will take advantage of the math class in the Java.lang base Class library and some basic trigonometric functions to uncover the fog for you. The knowledge of triangular geometry which is forgotten quickly is explained in detail in the last skyala.li of this paper.
Basic concepts of coordinates
First, let's look at a text translation in the Robocode API.
All coordinates are expressed as (x,y).
All coordinates are represented by X,y.
All coordinates are positive.
All coordinates are positive.
The origin (0,0) is on the bottom left to the screen.
Coordinate origin (0,0) in the lower left corner of the screen
Positive X is right. The right side of X is positive
Positive y is up. The top of Y is positive.
Figure 1 shows the coordinate system in the Robocode, the detailed description of the graph is shown in the article "Analysis of the direction of Robocode fundamentals".
Figure 1