Small Basic Turtle: Absolute Motion VS Relative Motion


When giving commands with absolute motion you’d be giving universal coordinates.

 

For example:

Turtle.X = 250

Turtle.Y = 150

 

Similarly, if you’re moving your turtle with absolute motion, you’d give the universal coordinates:

Turtle.MoveTo(x, y)

 

That would move your turtle’s angle toward the new coordinates, and then your turtle would move directly to the new coordinates. Let’s say the new coordinates were:

Turtle.MoveTo(50, 50)

 

If the turtle started at 250, 150, then he’d face and move to the upper left, diagonally, to 50, 50. He’d still be pointing in the same direction when he’s done.

 

In contrast, if you were going to move your turtle with relative motion, you’d move it a set distance, using this method:

Turtle.Move(150)

 

This example moves your turtle from your first coordinates (250, 150) forward 150 units.

 

Since your turtle faces up by default (unless you change his initial direction he’s facing), he moves straight up 150 units.

So the key difference is giving the Turtle object some coordinates (absolute) versus moving the turtle forward in the direction its facing (relative).

 

To move your turtle with an absolute angle, you’d use this method:

Turtle.Angle = 90

 

That would turn your turtle 90 degrees to the right. For example, let’s say this is your code.

Turtle.X = 250

Turtle.Y = 150

Turtle.Move(50)

Turtle.Angle = 90

 

So in this case, you set your X and Y coordinates (absolute) and move your turtle up 50 unites (relative), since your turtle faces up by default. And then you change the angle to 90 degrees from absolute coordinates, so it moves 90 degrees from pointing up, even if your turtle isn’t facing up!

 

Now, to contrast the absolute angle change, Small Basic provides a relative angle change:

Turtle.Turn(angle)

 

In this case, you plug the angle you want in, and change the angle from the direction the turtle is currently facing. So if you plug in 90, then your turtle turns 90 degrees to his right. So if he’s facing down, he’ll turn to his right and face to our left.

 

And then as a bit of a shortcut, Small Basic includes two relative motion turning methods, to turn the turtle quickly 90 degrees to his right or left:

Turtle.TurnRight()

Turtle.TurnLeft()

 

Please leave a comment with any corrections, suggestions, or questions!

 

Go to http://blogs.msdn.com/SmallBasic to download Small Basic for free and learn all about it!   

 

Have a great day!

   – Ninja Ed

Comments (3)

  1. A.Zaied says:

    helpful

  2. Computers Today (part 1 of 6)

    blogs.msdn.com/…/computers-today.aspx

    …..

    CS SPOTLIGHT: Girls in computer programming… why it matters!!!

    blogs.msdn.com/…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

    Computational Thinking – Videos & Papers by Jeannette Wing

    blogs.msdn.com/…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx

Skip to main content