8
$\begingroup$

I would like to draw in Mathematica two half arrows next to each other. Something like this: enter image description here

Here is my attempt:

x0 = -0.2;
y0 = -0.2;
k = -1;
dist = 0.02;(*distance between two arrows*)
c1 = Max[c /. Solve[y0 == k x0 + c, c]];
c2 = Max[c /. Solve[-y0 == k (-x0) + c, c]];
xA = x0 - dist/Sqrt[1 + k^2];
yA = k xA + c1;
xB = -x0 - dist/Sqrt[1 + k^2];
yB = k xB + c2;

Graphics[
{{Thick, Arrowheads[0.05], Arrow[{{x0, y0}, -{x0, y0}}],
Arrow[{{xB, yB}, {xA, yA}}]},
{White, Polygon[{{x0, y0}, -{x0, y0}, {xB, yB}, {xA, yA}}]}},
PlotRange -> {{-1., 1.}, {-1., 1.}}, Frame -> True, 
PlotRangeClipping -> True]

Form the code you can see that I've drawn two Arrows, while covering the right part of each of arrows by white Polygon. Here is my result:

enter image description here

(The arrows are under 45° degree angle which was done on purpose.)

I was wondering if there is some Graphics function in Mathematica for half arrow. Or if one can somehow modify the Arrow Graphics in order to get half arrow. I would be grateful for any suggestions.

$\endgroup$

3 Answers 3

6
$\begingroup$

We can also design a new arrow style by use Graphics

arrowStyle = 
  Graphics[{Black, Polygon[{{0, 0}, {-1, .2}, {-.8, 0}, {0, 0}}]}];
semiArrow = Arrowheads[{{0.2, 1, arrowStyle}}];
Graphics[{semiArrow, Arrow[{{0, 0}, {1, 1}}], 
  Arrow[{{1 + .1, 1 - .1}, {.1, -.1}}]}]

enter image description here

It is the first attempt. Late we can adjust the thickness of line and the position of arrow to get another style.

Update For 3D, we still need to draw an invisiable half arrow.

arrowStyle = 
  Graphics[{Black, FaceForm[Red], 
    Polygon[{{0, 0}, {-1, .2}, {-.8, 0}, {0, 0}}], EdgeForm[], 
    FaceForm[], Polygon[{{0, 0}, {-1, -.2}, {-.8, 0}, {0, 0}}]}];
semiArrow = Arrowheads[{{0.2, 1, arrowStyle}}];
Graphics3D[{semiArrow, Arrow[{{0, 0, 0}, {1, 1, 1}}]}]

enter image description here

$\endgroup$
5
$\begingroup$

This looks like the unicode character "rightwards harpoon over leftwards harpoon", with code U+21cc. It can be found here. We might use it in Mathematica like this:

harpoon = FromCharacterCode@FromDigits["21cc", 16];

Graphics[{
  Text[Style[harpoon, FontSize -> 25], {0, 0}],
  Text[Style[harpoon, FontSize -> 25], {10, 5}],
  Rotate[
   Text[Style[harpoon, FontSize -> 25], {5, 5}],
   30 Degree
   ]
  }]

Output

Other fonts might look more similar to your example.

$\endgroup$
2
$\begingroup$

Edit: Since I don't know your ultimate goal, here is my attempts.

    imSize = 100;
    poly = Polygon[{{0, 0}, {0, 2}, {9, 2}, {9, 4}, {14, 0}}];
 arrows = Rotate[Column[{Graphics[poly, ImageSize -> imSize], 
        Rotate[Graphics[poly, ImageSize -> imSize], 180 Degree]}, 
       Spacings -> 0], 45 Degree];
    Overlay[{Graphics[{FaceForm[], Rectangle[{-1, -1}, {1, 1}]}, 
       Frame -> True], arrows}, Alignment -> Center]

enter image description here


 poly = Polygon[{{0, 0}, {0, 2}, {9, 2}, {9, 4}, {14, 0}}];
 Rotate[Column[{Graphics[poly], Rotate[Graphics[poly], 180 Degree]}], 45 Degree]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.