Chapter 1
Positions in 2D

Positions in 2D have an x- and a y- coordinate, just as a point in a graph. In Esenthel the zero point is the middle of the screen. Positive values on the X-axis are to the right, negative values to the left. Positive values on the Y-axis are in the upper half of the screen, negative values on the lower half.


PIC

Figure 1.1: 2D coordinates.


The class Vec2 is used to represent a 2D coordinate. There are several ways to set the x and y values:

 
Vec2 pos; 
pos.x =  0.1;       // set the x value to  0.1 
pos.y = -0.3;       // set the y value to -0.3 
pos   =  0.5;       // both x and y are set to 0.5 
5pos.set(0.1, -0.3); // use the function set(float x, float y) 
                    // to assign both x and y  

Exercise
Where would these positions be located on the screen?