({{, (RefLink[AnglePath, paclet:ref/AnglePath])[{(Subscript[θ, 1]),(Subscript[θ, 2]),(Subscript[θ, 3]),…}] 
gives the list of 2D coordinates corresponding to a path that starts at {0,0}, then takes a series of steps of unit length at successive relative angles (Subscript[θ, i]). }, {, (RefLink[AnglePath, paclet:ref/AnglePath])[{{(Subscript[r, 1]),(Subscript[θ, 1])},{(Subscript[r, 2]),(Subscript[θ, 2])},{(Subscript[r, 3]),(Subscript[θ, 3])},…}]
takes successive steps of lengths (Subscript[r, i]). }, {, (RefLink[AnglePath, paclet:ref/AnglePath])[(Subscript[θ, 0]),{(Subscript[step, 1]),(Subscript[step, 2]),…}]
starts at angle (Subscript[θ, 0]) with respect to the x axis.}, {, (RefLink[AnglePath, paclet:ref/AnglePath])[{x,y},{(Subscript[step, 1]),(Subscript[step, 2]),…}]
starts at the point {x,y} with initial angle 0 with respect to the x axis.}, {, (RefLink[AnglePath, paclet:ref/AnglePath])[{{x,y},(Subscript[θ, 0])},{(Subscript[step, 1]),(Subscript[step, 2]),…}]
starts at {x,y} with initial angle (Subscript[θ, 0]) with respect to the x axis.}, {, (RefLink[AnglePath, paclet:ref/AnglePath])[{{x,y},{dx,dy}},{(Subscript[step, 1]),(Subscript[step, 2]),…}]
takes the first step to go from {x,y} to {x+dx,y+dy}.}, {, (RefLink[AnglePath, paclet:ref/AnglePath])[init,steps,form]
returns at each step the data of the form specified by form.}})

OpenersNotesSection(Spacer1)Details and Options

At each point reached in the formation of a path, (RefLink[AnglePath, paclet:ref/AnglePath]) in effect first rotates by the specified relative angle, then advances by the specified distance.

Unless explicitly given as (RefLink[Quantity, paclet:ref/Quantity]) objects, the angles (Subscript[θ, i]) are assumed to be in radians, increasing counterclockwise. (Multiply by (RefLink[Degree, paclet:ref/Degree]) to convert from degrees.)

In (RefLink[AnglePath, paclet:ref/AnglePath])[{(Subscript[θ, 1]),(Subscript[θ, 2]),(Subscript[θ, 3]),…}], the angle (Subscript[θ, 1]) is assumed to be relative to the x axis.

Possible choices for form in (RefLink[AnglePath, paclet:ref/AnglePath])[…,form] include:

The arguments of (RefLink[AnglePath, paclet:ref/AnglePath]) can be symbolic. They can also be (RefLink[Quantity, paclet:ref/Quantity]) objects.

(RefLink[AnglePath, paclet:ref/AnglePath]) has the option (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]), which determines the precision of numbers generated.

With the default setting (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision])->Automatic, exact numbers will be generated for exact input only for fairly short paths; for longer paths, machine precision will be used.

OpenersPrimaryExamplesSection(Spacer1)Examples  (31)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

Starting at {0,0} along the x axis, move several unit steps, rotating 90° before each step:

AnglePath[{90°,90°,90°}]

A polyline of three segments:

Graphics[Line[AnglePath[{{1.2,90.°},{2.1,130.°},{0.7,-85.°}}]]]

Advance 20 steps, always turning 110° toward the left:

Graphics[Line[AnglePath[ConstantArray[110°,20]]]]

Generate the transformation functions of a path:

transformations=AnglePath[{0,0},{{4,45°},{3(Sqrt[2]),-45°}},"RotationTranslation"]

Apply them to a turtle:

turtle=;
Graphics[GeometricTransformation[turtle[[1]],transformations]]

Use symbolic input:

AnglePath[{x,y},{{(Subscript[r, 1]),(Subscript[θ, 1])},{(Subscript[r, 2]),(Subscript[θ, 2])}}]

OpenersExampleSection1(Spacer1)Scope  (13)

OpenersExampleSubsection0(Spacer1)Steps Specification  (3)

Advance in unit steps of specified successive angles, starting from the x axis:

AnglePath[{90Degree,Pi/3,-Pi/4}]

Specify the lengths of the steps:

AnglePath[{{0.7,90Degree},{2.3,Pi/3},{3.5,-Pi/4}}]

Use (RefLink[Quantity, paclet:ref/Quantity]) objects in input:

AnglePath[Quantity[{20.,30.,-45.,120.},"AngularDegrees"]]

AnglePath[{{Quantity[4,"Feet"],Quantity[2,"Radians"]},{Quantity[2,"Meters"],Quantity[40,"AngularDegrees"]}}]

OpenersExampleSubsection1(Spacer1)Path Initialization  (4)

Specify the initial position:

AnglePath[{100,200},{90Degree,Pi/3,-Pi/4}]

AnglePath[{100,200},{{0.7,90Degree},{2.3,Pi/3},{3.5,-Pi/4}}]

Specify the initial orientation:

AnglePath[π/6,{90Degree,Pi/3,-Pi/4}]

AnglePath[π/6,{{0.7,90Degree},{2.3,Pi/3},{3.5,-Pi/4}}]

Specify both the initial position and orientation:

AnglePath[{{100,200},Pi/6},{90Degree,Pi/3,-Pi/4}]

AnglePath[{{100,200},Pi/6},{{0.7,90Degree},{2.3,Pi/3},{3.5,-Pi/4}}]

Use a Cartesian {dx,dy} specification for the initial orientation:

AnglePath[{{100,200},{Sqrt[3],1}},{{0.7,90Degree},{2.3,Pi/3},{3.5,-Pi/4}}]

OpenersExampleSubsection2(Spacer1)Forms of Output  (6)

By default, (RefLink[AnglePath, paclet:ref/AnglePath]) returns the position reached at each step:

pos1=AnglePath[{0,0},{(Subscript[θ, 1]),(Subscript[θ, 2]),(Subscript[θ, 3])}];
pos2=AnglePath[{0,0},{(Subscript[θ, 1]),(Subscript[θ, 2]),(Subscript[θ, 3])},"Position"];

pos1===pos2

Compute the orientation of each local frame with respect to the previous local frame:

AnglePath[{1,1},{π/3,π/2,-2π/3},"RelativeMatrix"];

Map[MatrixForm,%]

Compute the orientation of each local frame with respect to the global frame:

AnglePath[{1,1},{π/3,π/2,-2π/3},"FrameMatrix"];

Map[MatrixForm,%]

Compute the angle determining the orientation of each local frame in the global frame:

AnglePath[{1,1},{π/3,π/2,-2π/3},"FrameAngle"]

Generate rotation-translation transformations from the initial step:

transformations=AnglePath[{1,1},{{1,π/2},{3,-π/4}},"RotationTranslation"]

Apply them to a triangle:

triangle=Triangle[{{-1,0},{1,0},{0,10}}];
Graphics[{Opacity[0.3],GeometricTransformation[triangle,transformations]}]

Produce different types of output with one (RefLink[AnglePath, paclet:ref/AnglePath]) call:

types={"RelativeMatrix","Position","RotationTranslation"};
path=AnglePath[{1,1},{{1,π/2},{3,-π/4}},types];

The first elements of the triples are the rotation matrices with respect to the previous frame:

Map[MatrixForm,path[[All,1]]]

The second elements are the positions:

path[[All,2]]

The third elements are the transformation functions from the initial frame:

path[[All,3]]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection3(Spacer1)WorkingPrecision  (1)

By default, (RefLink[AnglePath, paclet:ref/AnglePath]) with exact input gives exact numbers for short paths and machine numbers for long paths:

AnglePath[Range[10]Pi]//Last

AnglePath[Range[10000]Pi]//Last

Specify infinite working precision to perform exact, but slower computations:

AnglePath[Range[10000]Pi,WorkingPrecision->Infinity]//Last

Use any specified precision for the computations:

AnglePath[Range[10000]Pi,WorkingPrecision->50]//Last

OpenersExampleSection3(Spacer1)Applications  (3)

Make a random walk where successive steps change direction by at most 20°:

Graphics[Line[AnglePath[RandomReal[{-20°,20°},1000]]]]

Generate a dragon curve:

Graphics[Line[AnglePath[{90°,-90°}[[1+Nest[Join[#,{0},Reverse[1-#]]&,{0},10]]]]]]

Generate a Koch snowflake curve:

Graphics[Line[AnglePath[Array[ThueMorse,4096]2 Pi/3]]]

Another pattern based on the Thue–Morse sequence:

Graphics[Line[AnglePath[Array[ThueMorse,4096]2 Pi/5]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

Angles are accumulated in subsequent steps, starting with (Subscript[θ, 0]):

AnglePath[{{0,0},(Subscript[θ, 0])},Array[(Subscript[θ, #])&,{6}]]

These two results are identical:

AnglePath[{{x,y},(Subscript[θ, 0])},{{(Subscript[r, 1]),(Subscript[θ, 1])},{(Subscript[r, 2]),(Subscript[θ, 2])}}]

%===Rest@AnglePath[{x,y},{{0,(Subscript[θ, 0])},{(Subscript[r, 1]),(Subscript[θ, 1])},{(Subscript[r, 2]),(Subscript[θ, 2])}}]

Take 100 random angles between -(π/2) and (π/2):

angles=RandomReal[{-Pi/2,Pi/2},100];

Considered as absolute angles, they represent on average a collection of steps toward the right:

Graphics[Line[FoldList[AngleVector,{0,0},angles]]]

Considered as relative angles, the path may evolve in any possible direction. The total length is the same:

Graphics[Line[AnglePath[{0,0},angles]]]

Global frame rotations can be obtained as multiplications of all previous relative rotations:

angles=N@{{π/3,0},{π/2,-π/6}};

framematrices=AnglePath[{1,1},angles,"FrameMatrix"];
Map[MatrixForm,%]

framematrices==FoldList[Dot,AnglePath[{1,1},angles,"RelativeMatrix"]]

Compute the positions for a path with the following inputs:

p0={x0,y0};
angles=Array[θ,10];

positions=AnglePath[p0,angles];

Each new position can be computed as a displacement along a rotation of the initial x axis:

framematrices=AnglePath[p0,angles,"FrameMatrix"];

positions==FoldList[#1+#2.{1,0}&,p0,Rest[framematrices]]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

When using the notation {{x,y},{dx,dy}} for the first argument, {dx,dy} determines the initial orientation, not the position of the next point:

AnglePath[{{0,0},{0.001,0.002}},{{1,0}}]

%===AnglePath[{{0,0},ArcTan[0.001,0.002]},{{1,0}}]

OpenersExampleSection6(Spacer1)Interactive Examples  (1)

DynamicModule[{turtle,steps={},path,points},
turtle=;
Manipulate[
path=AnglePath[{0.,0.},steps,{"Position","FrameMatrix"}];
points=path[[All,1]];
Graphics[{
Line[points],GeometricTransformation[turtle[[1]],AffineTransform[{path[[-1,2]].RotationMatrix[θ],Last[points]}]],
Point[points],
White, Point[{{-8,-8},{8,8}}]},
Axes->True,
PlotRange->All,
ImageSize->{420,420}
],
Row[{Control[{{r,1},0,10}],Spacer[23],Control[{{fixr,True,"Fixed"},{True,False}}]}],
Row[{Control[{{θ,0},-Pi,Pi}],Spacer[20],Control[{{fixθ,False,"Fixed"},{True,False}}]}],
Button["Next step",AppendTo[steps,{r,θ}];If[Not[fixr],r=1.];If[Not[fixθ],θ=0.]],
Button["Restart",{steps={},r=1.,θ=0.}]
]
]

OpenersExampleSection7(Spacer1)Neat Examples  (2)

Graphics[Line[AnglePath[Range[0,10,.01]]]]

Graphics[Line[AnglePath[Range[0,100,.01]]]]

Graphics[Line[AnglePath[Table[t Sin[t],{t,0,50,.01}]]]]

Graphics[Line[AnglePath[N@Range[10000]]]]

Graphics[Line[AnglePath[N@Range[100000]]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[AnglePath3D, paclet:ref/AnglePath3D])  ▪  (RefLink[AngleVector, paclet:ref/AngleVector])  ▪  (RefLink[Sin, paclet:ref/Sin])  ▪  (RefLink[Cos, paclet:ref/Cos])  ▪  (RefLink[Degree, paclet:ref/Degree])  ▪  (RefLink[AbsArg, paclet:ref/AbsArg])  ▪  (RefLink[GeoPath, paclet:ref/GeoPath])  ▪  (RefLink[FoldList, paclet:ref/FoldList])  ▪  (RefLink[Accumulate, paclet:ref/Accumulate])  ▪  (RefLink[Rotate, paclet:ref/Rotate])  ▪  (RefLink[SubstitutionSystem, paclet:ref/SubstitutionSystem])  ▪  (RefLink[TuringMachine, paclet:ref/TuringMachine])  ▪  (RefLink[GeometricTransformation, paclet:ref/GeometricTransformation])  ▪  (RefLink[TranslationTransform, paclet:ref/TranslationTransform])  ▪  (RefLink[RotationTransform, paclet:ref/RotationTransform])  ▪  (RefLink[PolygonAngle, paclet:ref/PolygonAngle])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Iterated Maps & Fractals, paclet:guide/IteratedMapsAndFractals])}, {▪(RefLinkPlain[Computational Systems, paclet:guide/ComputationalSystemsAndDiscovery])}, {▪(RefLinkPlain[Angles and Polar Coordinates, paclet:guide/AnglesAndPolarCoordinates])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/17-units.html])(WebLink[: Units, https://www.wolfram.com/language/elementary-introduction/17-units.html])}})}})