Coordinates

From CodeStuff
Jump to: navigation, search

What exactly does this line mean?

   drawCircle(50,60,30)

It is easy enough to figure out what the function is for. drawCircle quite clearly indicates that if you want to draw a circle you have probably come to the right place, but what of the three numbers passed to the function. The things the drawCircle command needs to know is how big to draw the circle and where to draw the circle.

The last number is easy. That's how big the circle is. The first two numbers work as a pair to indicate position.

x,y Coordinates[edit]

The two values indicating position are traditionally named X and Y. The only reason the names X and Y are used is they were convenient letters at the end of the alphabet, they weren't doing much at the time so people decided to use them to stop them being so lazy.

The x coordinate is used to say how far across something is. the y coordinate is used to say how far down something is.

As a pair the values 0,0 indicate the top-left corner. Which is to say 0 from the left and 0 from the top. The pair 50, 200 would indicate a position 50 from the left and 200 from the top.

In Mathematics coordinates often use the bottom-left corner and move up and to the right. If negative values are used it is common to start in the center. In computer graphics it is more common to start at the top left of the display.

Computer graphics were designed with television displays in mind, Televisions update the screen a dot at a time in the same order that you read a book. Starting at the top left.

To help you understand This program draws horizontal and vertical lines showing the x and y positions.