TurtleGraphics - Online Manual

turtle_getpos {TurtleGraphics}R Documentation

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()

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_backward, turtle_forward, turtle_move; turtle_col, turtle_lty, turtle_lwd, turtle_param; turtle_down, turtle_up; turtle_do; turtle_goto, turtle_setangle, turtle_setpos; turtle_hide, turtle_show; turtle_init; turtle_left, turtle_right, turtle_turn; turtle_reset; turtle_status

Examples

turtle_init()
turtle_getpos()["x"] # x coordinate
turtle_getpos()["y"] # y coordinate

[Package TurtleGraphics version 1.0-5 Index]