EZ Math Movie, Tutorials, Turtle Graphics, setX, setY, and setXY


Go to a certain (x, y) location.

The command setXY moves the turtle to a specific point on the (x, y) plane. For example, if you wanted to move the turtle to the coordinates (4, 5), then you would use this code:

setXY(4, 5);

If the pen is down, then the turtle will draw a line from its original location to the new one set by setXY. The turtle's heading does not change as it moves to its new spot.

Moving horizontally

You can make the turtle move horizontally with the command setX. This command is used to change only the x-coordinate of the turtle's location. The y-coordinate stays the same. If you wanted to move the turtle to a point where x = 6, then this code would do that:

setX(6);

The turtle will draw along its journey if the pen is down, and, again the turtle will not spin as it moves.

Moving vertically

Use the command setY to move the turtle up or down. This command will change only the y-coordinate of the turtle's location. To move the turtle to a point where y = -4, use this code:

setY(-4);

Again, there is not spinning during movement, and drawing only happens if the pen is down.

Moving with setXY, setX, and setY

setXY, setX, setY animation

Running the example program

The loop code cycles only once. At its start the graph is prepared, and the turtle is sent to the origin with the home command. Then the turtle is moved about using setXY, setX, and setY.


The example program

0ptions
Angle measurement: Degrees Radians

Go on input

Bounds:
Sorry, apparently this browser does not support HTML 5 canvas tag graphics.
Printer

Edit: Runtime          View: Starter Suggestion

To runtime:

Storage:

Editor width: Normal Wide


		

	


		

	


		

	

And....

Next tutorial: setH

 

Here is a link to a related article at EZ Programing Demos:

Set x and y


All contents of EZ Math Movie are copyrighted: Copyright 2011, Edward A. Zobel. All rights reserved.



Other sites you may find interesting

Zona Land Education Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Here is the link: zonalandeducation.com




EZ Programing Demos Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Here is the link: ezprogramingdemos.com



Custom Search

Name:
Domain:

Name
0


Name:
Name
0