Gambar setengah panah
Saya ingin menggambar dalam dua setengah panah Mathematica di samping satu sama lain. Sesuatu seperti ini:
Inilah usaha saya:
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]
Bentuk kode Anda dapat melihat bahwa saya telah menggambar dua Arrows, sementara menutupi bagian kanan dari masing-masing panah dengan warna putih Polygon. Ini hasil saya:
(Panah berada di bawah sudut 45 ° derajat yang dilakukan dengan sengaja.)
Saya bertanya-tanya apakah ada beberapa Graphicsfungsi di Mathematica untuk panah setengah . Atau jika seseorang entah bagaimana bisa memodifikasi Arrow Graphicsuntuk mendapatkan setengah panah. Saya akan berterima kasih atas saran apa pun.
Jawaban
Kami juga dapat mendesain gaya panah baru dengan menggunakan 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?
Ini adalah percobaan pertama. Terlambat kita bisa mengatur ketebalan garis dan posisi panah untuk mendapatkan gaya lain.
Update Kode diatas tidak cocok untuk 3D, kenapa tidak?
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}}]}]
Ini terlihat seperti karakter unicode "rightwards harpoon over leftwards harpoon", dengan kode U + 21cc. Itu bisa ditemukan disini . Kami mungkin menggunakannya di Mathematica seperti ini:
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
]
}]
Font lain mungkin terlihat lebih mirip dengan contoh Anda.
Sunting: Karena saya tidak tahu tujuan akhir Anda, inilah upaya saya.
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]