Pencil Code Reference > Angles
An angle can be used to determine how far an object rotates when using certain commands. One example of such a command is lt.
Angles are also used to determine the direction of one object from another, such as in the
The direction from one object to another object is an angle. This angle is a value between -180 and 180 and like coordinates, the angle is relative to the environment, not the object itself. This means that, no matter which direction the object is currently facing, the direction will remain the same between the same locations.
In the example below, the direction from the turtle to the mouse cursor is displayed at the top, and the relative angles from the turtle (in this case, the coordinates used in the rt command) are displayed in the wheel around the turtle. When the mouse button is clicked, the turtle will turn towards the cursor's location.
###Interior vs Exterior Angles
It is important to note that the angles used by commands (such as lt and rt) are exterior angles. The only case in which the interior and exterior angles are the same is when drawing a 90 degree angle.
To draw an (interior) angle of a certain degree, you need to find the exterior angle to use in the code. The exterior angle is equal to 180 degrees minus the desired interior angle.
Instead of using:
like in the example on the left, we need to use:
The following is an example of the differences between using the interior angle (left) of 60 degrees and the exterior angle (right) of 120 degrees.
For example, when drawing an equillateral triangle (a triangle with all angles equal to 60 degrees and all sides equal in length), if you use 60 degree angles, it will not turn out correctly.
As you can see, using an angle of 60 degrees did not create a triangle. However, if you were to use an angle of 120 degrees, it works.↑