turtle_getpos: Get the Turtle's Current Position and Direction

Description Usage Details Value See Also Examples

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

1
2
3

Details

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

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.

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

1
2
3
turtle_init()
turtle_getpos()["x"] # x coordinate
turtle_getpos()["y"] # y coordinate

TurtleGraphics documentation built on May 2, 2019, 1:07 p.m.