Disegna una mezza freccia

Sep 09 2020

Vorrei disegnare in Mathematica due mezze frecce una accanto all'altra. Qualcosa come questo:

Ecco il mio tentativo:

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]

Dal codice puoi vedere che ho disegnato due Arrows, coprendo la parte destra di ciascuna delle frecce di bianco Polygon. Ecco il mio risultato:

(Le frecce hanno un angolo inferiore a 45 ° che è stato fatto apposta.)

Mi chiedevo se ci fosse qualche Graphicsfunzione in Mathematica per la mezza freccia . O se si può in qualche modo modificare il Arrow Graphicsper ottenere una mezza freccia. Sarei grato per qualsiasi suggerimento.

Risposte

5 cvgmt Sep 09 2020 at 23:11

Possiamo anche progettare un nuovo stile di freccia tramite l'uso 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}}]}]The above codes does not suitable for 3D,why not?

È il primo tentativo. Più tardi possiamo regolare lo spessore della linea e la posizione della freccia per ottenere un altro stile.

Aggiorna I codici precedenti non sono adatti per il 3D, perché no?

 Clear["`*"];
 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}}]}]

4 C.E. Sep 09 2020 at 15:50

Questo assomiglia al carattere unicode "arpione verso destra su arpione verso sinistra", con codice U + 21cc. Può essere trovato qui . Potremmo usarlo in Mathematica in questo modo:

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
   ]
  }]

Altri caratteri potrebbero essere più simili al tuo esempio.

1 OkkesDulgerci Sep 10 2020 at 09:06

Modifica: poiché non conosco il tuo obiettivo finale, ecco i miei tentativi.

    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]


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