ELLIPSEARC2arc.angle
x.semiaxis
y.semiaxis
start.angle
Moves the turtle clockwise over an elliptic arc.
The arc spans arc.angle
degrees of the ellipse, starting at the point described by start.angle
degrees and ending at the point described by (start.angle
+ arc.angle
) degrees.
The size and shape of the elliptic arc can visualized in the following manner.
First, imagine an ellipse drawn in the center of the screen such that the x.semiaxis
is the distance from the center to the ellipse along the X-axis and y.semiaxis
is the distance from the center to the ellipse along the Y-axis.
ELLIPSEARC2 draws part of this ellipse, an arc between two points on the ellipse.
The starting point for this arc can be visualized by imagining a turtle at the ellipse's center with a HEADING of start.angle
.
Wherever this turtle intersects the ellipse as it moves forward is the starting point of the arc.
The ending point can be similarly imagined as if that turtle had turned RIGHT an additional arc.angle
degrees before moving forward to intersect the ellipse.
Now that you have visualized size and shape of the elliptic arc, you can visualize its position and orientation as follows. First, translate the elliptic arc such that its start position is at the turtle's current position. Next, rotate the elliptic arc such that a line that is tangent to the arc at its start position aligns with the turtle's current HEADING.
Despite the confusing behavior, it is straight-forward to use ELLIPSEARC2 to iteratively draw contiguous segments of an ellipse of equal sweeps.
If your first call has a start.angle
of 0 and in each subsequent call, the start.angle
is the sum of all arc.angle
inputs previously given, you'll end drawing contiguous elliptic arcs.
Normally, the arc is drawn in clockwise direction, but if the arc.angle
input is negative, then the turtle moves backward in a counter-clockwise direction.
A simple 2D example:
ELLIPSEARC2 90 100 200 0
ELLIPSEARC2 90 50 100 0
A 2D ellipse built out of multiple consecutive arcs:
SETPENSIZE 10
SETPENCOLOR "RED
ELLIPSEARC2 90 150 100 0
SETPENCOLOR "LIME
ELLIPSEARC2 90 150 100 90
SETPENCOLOR "BLUE
ELLIPSEARC2 90 150 100 180
SETPENCOLOR "YELLOW
ELLIPSEARC2 90 150 100 270
The following draws an ellipse with a dashed line using multiple consecutive arcs. Note that the arc segments are equal sweeps (in degrees) which are not equal lengths (in turtle steps).
REPEAT 18 [
PENUP
ELLIPSEARC2 10 50 200 REPCOUNT*20-20
PENDOWN
ELLIPSEARC2 10 50 200 REPCOUNT*20-10
]
A 3D example:
PERSPECTIVE
REPEAT 72 [ELLIPSEARC2 90 50 100 0 RIGHTROLL 5]
ELLIPSEARC |