# How to draw arrows of certain length from a point, at a certain angle?

What's the specification to draw arrows of a certain length (from a reference point), at a given angle?

Say, I want to draw an arrow of length 1 at 0 degrees, and one of length 0.5 at 90 degrees, each arrow starting at a giving originPt. Ideally, I'd like a function where I give as argument a list of arrowSpecs, like this:

(*Arrow list {arrowColor, originPt, lengthFromOrigin, angle}*)
originPt = {0,0};
arrowSpecs = {{Blue,originPt,1,0},{Red,originPt,0.5,90}}

(*My desired function*)
arrowDrawing[arrowSpecs]

Getting this:

Note that the originPt could be different for every arrow, here just for simplicity I used the same.

Thanks!

originPt = {0, 0};
arrowSpecs = {{Blue, originPt, 1, 0}, {Red, originPt, 0.5, 90 Degree}};

arrowDrawing[specs_] :=
Arrow[{#[[2]], #[[2]] + {#[[3]] Cos[#[[4]]], #[[3]] Sin[#[[4]]]}}]} & /@
specs]

arrowDrawing[arrowSpecs]

Note the usage of Degree when defining the angle.

• If we test with originPt = RandomReal[{-10, 10}, 2], what happens if originPt is not (0, 0)? Does Arrow[{#[[2]], {#[[3]] Cos[#[[4]]], #[[3]] Sin[#[[4]]]} + #[[2]]}]} & /@ specs solve the problem? Commented Aug 29, 2021 at 18:57
• @creidhne, yes, sorry, I have fixed the problem. Commented Aug 29, 2021 at 20:35

You can use the function AnglePath for this purpose:

toArrow[{color_, orig_, len_, angle_}] := {
color,
Arrow @ AnglePath[orig, {{len,angle}}]
}

For example:

arrowSpecs = {{Blue, {1, 1}, 1, 0}, {Red, {-1, -1}, 0.5, 90 Degree}};
Graphics[toArrow /@ arrowSpecs, Axes->True]

ClearAll[transformedArrow]
transformedArrow[{style_, origin_, length_, angle_}] :=
{style,
Arrow @ AffineTransform[{length RotationMatrix @ angle, origin}] @ {{0, 0}, {1, 0}}}

Examples:

arrowSpecs = {{Directive[AbsoluteThickness[5], Arrowheads[Large], Blue], {1,1}, 1, π/4},
{Red, {-1, 0}, 0.5, 90 Degree}};

Graphics[transformedArrow /@ arrowSpecs]

SeedRandom[1]
aSpecs = Table[{RandomColor[], RandomReal[{-2, 2}, 2],
RandomReal[{.5, 2}], RandomReal[{0, 2 Pi}]}, 20];

Graphics[{Thick, transformedArrow /@ aSpecs}, Axes -> True]