public class TurtleState extends Object
PositionHeading
and a stack of previous
PositionHeadings for a Turtle
.Modifier and Type | Field and Description |
---|---|
static PositionHeading |
DEFAULT_POSITION |
Constructor and Description |
---|
TurtleState(PositionHeading positionHeading,
BlockingDeque<PositionHeading> posStack)
Creates a new TurtleState (immutable).
|
Modifier and Type | Method and Description |
---|---|
static TurtleState |
defaultState()
Returns a TurtleState which starts at (0,0), pointing to 0.0 radians, and
has an empty PositionHeading stack.
|
float |
getAngle()
Get the current angle of the turtle in radians.
|
processing.core.PVector |
getPosition()
Get the current position of the turtle as a PVector.
|
TurtleState |
move(float dist)
Moves the turtle along the current heading by a specified distance.
|
TurtleState |
popPositionHeading()
Pop a PositionHeading off the top of the stack.
|
TurtleState |
pushPositionHeading()
Push the current PositionHeading onto the stack.
|
TurtleState |
turn(float angle)
Turns the turtle by the specified angle in radians.
|
public static final PositionHeading DEFAULT_POSITION
public TurtleState(PositionHeading positionHeading, BlockingDeque<PositionHeading> posStack)
positionHeading
- the position and heading to start fromposStack
- a stack of positions/headingspublic processing.core.PVector getPosition()
public float getAngle()
public TurtleState move(float dist)
dist
- the distance to movepublic TurtleState turn(float angle)
angle
- the angle to turn bypublic TurtleState pushPositionHeading()
public TurtleState popPositionHeading()
public static TurtleState defaultState()
Processing Library loom by Cora Johnson-Roberson. (c) 2014-2016