Difference between revisions of "Coordinates"

From CodeStuff
Jump to: navigation, search
(x,y Coordinates)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
What exactly does this line mean?
 
What exactly does this line mean?
 
     drawCircle(50,60,30)
 
     drawCircle(50,60,30)
It is easy enough to figure out what the function is for.  drawCircle quite clearly indicate 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.  
+
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.
 
The last number is easy.  That's how big the circle is.  The first two numbers work as a pair to indicate position.
Line 14: Line 14:
 
The pair 50, 200 would indicate a position 50 from the left and 200 from the top.
 
The pair 50, 200 would indicate a position 50 from the left and 200 from the top.
  
Mathematicians often use the bottom-left corner and move up.  Ignore them, they're wrong :-P.
+
In Mathematics coordinates often use the bottom-left corner and move up and to the rightIf 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.
 
To help you understand This program draws horizontal and vertical lines showing the x and y positions.
Line 24: Line 26:
 
   if (x > 640) x=0;
 
   if (x > 640) x=0;
  
   y=y+1
+
   y=y+1;
 
   if (y > 480) y=1;
 
   if (y > 480) y=1;
 
}
 
}
Line 41: Line 43:
 
   setColour("black");
 
   setColour("black");
 
   drawCircle(x,y,10);
 
   drawCircle(x,y,10);
 
+
 
 +
  var m=getMousePosition();
 +
 
 +
  drawCircle(m.x,m.y,20);
 +
  print (m, m.x-20,m.y-20);
 +
 
 
}
 
}
  

Latest revision as of 00:28, 21 June 2017

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.