TurtleGraphics (version 1.0-8)

turtle_getpos: Get the Turtle's Current Position and Direction

Description

turtle_getpos returns the Turtle's current position on the plane.

turtle_getangle returns the Turtle's current direction, in degrees. An angle of 0 represents a north-facing Turtle.

Usage

turtle_getpos()

turtle_getangle()

Arguments

Value

Both functions return a (named) numeric vector. turtle_getpos returns a vector of length two which specifies the x and y coordinates. The turtle_getangle returns the angle.

Details

The terrarium must be initialized prior to using these functions, see turtle_init.

See Also

Other TurtleGraphics: TurtleGraphics-package, turtle_do, turtle_goto, turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up

Examples

Run this code
# NOT RUN {
turtle_init()
turtle_getpos()["x"] # x coordinate
turtle_getpos()["y"] # y coordinate

# }

Run the code above in your browser using DataLab