mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +00:00
Fix center of mass graphics
This commit is contained in:
parent
1b93a57df2
commit
d9c8d65e73
3 changed files with 96 additions and 93 deletions
|
@ -1416,9 +1416,9 @@ version = "0.33.14"
|
||||||
|
|
||||||
[[deps.StatsFuns]]
|
[[deps.StatsFuns]]
|
||||||
deps = ["ChainRulesCore", "InverseFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
deps = ["ChainRulesCore", "InverseFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
|
||||||
git-tree-sha1 = "bedb3e17cc1d94ce0e6e66d3afa47157978ba404"
|
git-tree-sha1 = "f35e1879a71cca95f4826a14cdbf0b9e253ed918"
|
||||||
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
|
||||||
version = "0.9.14"
|
version = "0.9.15"
|
||||||
|
|
||||||
[[deps.StructArrays]]
|
[[deps.StructArrays]]
|
||||||
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
|
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name = "ReCo"
|
name = "ReCo"
|
||||||
uuid = "b25f7548-fcc9-4c91-bc24-841b54f4dd54"
|
uuid = "b25f7548-fcc9-4c91-bc24-841b54f4dd54"
|
||||||
authors = ["MoBit <mo8it@protonmail.com>"]
|
authors = ["MoBit <mo8it@protonmail.com>"]
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
|
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
|
||||||
|
@ -21,6 +21,7 @@ LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
|
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
|
||||||
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
|
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
|
||||||
|
MathTeXEngine = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
|
||||||
ProfileView = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
|
ProfileView = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
|
||||||
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
|
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
|
|
|
@ -1,124 +1,126 @@
|
||||||
using Luxor
|
using Luxor
|
||||||
|
|
||||||
using ReCo: restrict_coordinate, project_to_unit_circle, project_back_from_unit_circle
|
using ReCo: ReCo
|
||||||
|
|
||||||
##
|
function gen_COM_graphics()
|
||||||
|
box_length = 100
|
||||||
|
box_height = 100
|
||||||
|
|
||||||
box_length = 100
|
L = 0.35 * box_length
|
||||||
box_height = 100
|
|
||||||
|
|
||||||
L = 0.35 * box_length
|
R = 0.35 * box_length
|
||||||
|
|
||||||
R = 0.35 * box_length
|
A = -0.9 * L
|
||||||
|
B = 0.65 * L
|
||||||
|
pr = 0.03 * L
|
||||||
|
|
||||||
A = -0.9 * L
|
Ap_vec = Vector(ReCo.Shape.project_to_unit_circle(A, L))
|
||||||
B = 0.65 * L
|
Bp_vec = Vector(ReCo.Shape.project_to_unit_circle(B, L))
|
||||||
pr = 0.03 * L
|
for p in (Ap_vec, Bp_vec)
|
||||||
|
|
||||||
Ap_vec = Vector(project_to_unit_circle(A, L))
|
|
||||||
Bp_vec = Vector(project_to_unit_circle(B, L))
|
|
||||||
for p in (Ap_vec, Bp_vec)
|
|
||||||
p[2] *= -1
|
p[2] *= -1
|
||||||
end
|
end
|
||||||
|
|
||||||
Ap = Point(Ap_vec[1], Ap_vec[2])
|
Ap = Point(Ap_vec[1], Ap_vec[2])
|
||||||
Bp = Point(Bp_vec[1], Bp_vec[2])
|
Bp = Point(Bp_vec[1], Bp_vec[2])
|
||||||
|
|
||||||
M = R * ((Ap + Bp) / 2)
|
M = R * ((Ap + Bp) / 2)
|
||||||
|
|
||||||
θ = atan(-M[2], M[1])
|
θ = atan(-M[2], M[1])
|
||||||
|
|
||||||
COM = project_back_from_unit_circle(θ, L)
|
COM = ReCo.Shape.project_back_from_unit_circle(θ, L)
|
||||||
si, co = sincos(θ)
|
si, co = sincos(θ)
|
||||||
COMp = R * Point(co, -si)
|
COMp = R * Point(co, -si)
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
graphics_export_dir = "exports/graphics"
|
graphics_export_dir = "exports/graphics"
|
||||||
mkpath(graphics_export_dir)
|
mkpath(graphics_export_dir)
|
||||||
|
|
||||||
Drawing(box_length, box_height, "$graphics_export_dir/line.pdf")
|
Drawing(box_length, box_height, "$graphics_export_dir/line.pdf")
|
||||||
origin()
|
origin()
|
||||||
|
|
||||||
setcolor("black")
|
setcolor("black")
|
||||||
arrow(Point(-1.1 * L, 0), Point(1.2 * L, 0); arrowheadlength=0.1 * L, linewidth=0.8)
|
arrow(Point(-1.1 * L, 0), Point(1.2 * L, 0); arrowheadlength=0.1 * L, linewidth=0.8)
|
||||||
|
|
||||||
green_orange = blend(Point(-1.5 * L, 0), Point(1.5 * L, 0))
|
green_orange = blend(Point(-1.5 * L, 0), Point(1.5 * L, 0))
|
||||||
addstop(green_orange, 0.0, "orange")
|
addstop(green_orange, 0.0, "orange")
|
||||||
addstop(green_orange, (L) / (3 * L), "green")
|
addstop(green_orange, (L) / (3 * L), "green")
|
||||||
addstop(green_orange, (2 * L) / (3 * L), "orange")
|
addstop(green_orange, (2 * L) / (3 * L), "orange")
|
||||||
addstop(green_orange, 1.0, "green")
|
addstop(green_orange, 1.0, "green")
|
||||||
setblend(green_orange)
|
setblend(green_orange)
|
||||||
setline(0.8)
|
setline(0.8)
|
||||||
line(Point(-L, 0), Point(L, 0), :stroke)
|
line(Point(-L, 0), Point(L, 0), :stroke)
|
||||||
|
|
||||||
setcolor("red")
|
setcolor("red")
|
||||||
setline(0.5)
|
setline(0.5)
|
||||||
for x in (-L, L)
|
for x in (-L, L)
|
||||||
line(Point(x, 0.05 * L), Point(x, -0.05 * L), :stroke)
|
line(Point(x, 0.05 * L), Point(x, -0.05 * L), :stroke)
|
||||||
end
|
end
|
||||||
|
|
||||||
setcolor("cyan3")
|
setcolor("cyan3")
|
||||||
line(Point(0, 0.05 * L), Point(0, -0.05 * L), :stroke)
|
line(Point(0, 0.05 * L), Point(0, -0.05 * L), :stroke)
|
||||||
|
|
||||||
setcolor("blue")
|
setcolor("blue")
|
||||||
for p in (A, B)
|
for p in (A, B)
|
||||||
circle(Point(p, 0), pr, :fill)
|
circle(Point(p, 0), pr, :fill)
|
||||||
end
|
end
|
||||||
|
|
||||||
setcolor("brown")
|
setcolor("brown")
|
||||||
circle(Point(COM, 0), pr, :fill)
|
circle(Point(COM, 0), pr, :fill)
|
||||||
|
|
||||||
setcolor("black")
|
setcolor("black")
|
||||||
fontsize(5)
|
fontsize(5)
|
||||||
text("x", Point(1.2 * L, 0.035 * L))
|
text("x", Point(1.2 * L, 0.038 * L))
|
||||||
text("-L", Point(-L - 0.08 * L, 0.18 * L))
|
text("-L", Point(-L - 0.07 * L, 0.18 * L))
|
||||||
text("0", Point(0 - 0.035 * L, 0.18 * L))
|
text("0", Point(0 - 0.035 * L, 0.18 * L))
|
||||||
text("+L", Point(L - 0.08 * L, 0.18 * L))
|
text("+L", Point(L - 0.07 * L, 0.18 * L))
|
||||||
text("A", Point(A - 0.04 * L, -0.06 * L))
|
text("A", Point(A - 0.038 * L, -0.06 * L))
|
||||||
text("B", Point(B - 0.04 * L, -0.06 * L))
|
text("B", Point(B - 0.038 * L, -0.06 * L))
|
||||||
text("COM", Point(COM - 0.125 * L, -0.06 * L))
|
text("COM", Point(COM - 0.108 * L, -0.06 * L))
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
Drawing(box_length, box_height, "$graphics_export_dir/circle.pdf")
|
Drawing(box_length, box_height, "$graphics_export_dir/circle.pdf")
|
||||||
origin()
|
origin()
|
||||||
|
|
||||||
arrow(Point(-1.2 * R, 0), Point(1.2 * R, 0); arrowheadlength=0.1 * R, linewidth=0.8)
|
arrow(Point(-1.2 * R, 0), Point(1.2 * R, 0); arrowheadlength=0.1 * R, linewidth=0.8)
|
||||||
arrow(Point(0, 1.2 * R), Point(0, -1.2 * R); arrowheadlength=0.1 * R, linewidth=0.8)
|
arrow(Point(0, 1.2 * R), Point(0, -1.2 * R); arrowheadlength=0.1 * R, linewidth=0.8)
|
||||||
|
|
||||||
setcolor("black")
|
setcolor("black")
|
||||||
fontsize(5)
|
fontsize(5)
|
||||||
text("α", Point(1.22 * R, 0.035 * R))
|
text("α", Point(1.22 * R, 0.035 * R))
|
||||||
text("β", Point(-0.04 * R, -1.23 * R))
|
text("β", Point(-0.04 * R, -1.23 * R))
|
||||||
|
|
||||||
orange_green = blend(Point(0, -R), Point(0, R), "green", "orange")
|
orange_green = blend(Point(0, -R), Point(0, R), "green", "orange")
|
||||||
setblend(orange_green)
|
setblend(orange_green)
|
||||||
setline(0.8)
|
setline(0.8)
|
||||||
circle(Point(0, 0), R, :stroke)
|
circle(Point(0, 0), R, :stroke)
|
||||||
|
|
||||||
setcolor("red")
|
setcolor("red")
|
||||||
setline(0.5)
|
setline(0.5)
|
||||||
line(Point(1.05 * R, 0), Point(0.95 * R, 0), :stroke)
|
line(Point(1.05 * R, 0), Point(0.95 * R, 0), :stroke)
|
||||||
setcolor("cyan3")
|
setcolor("cyan3")
|
||||||
line(Point(-1.05 * R, 0), Point(-0.95 * R, 0), :stroke)
|
line(Point(-1.05 * R, 0), Point(-0.95 * R, 0), :stroke)
|
||||||
|
|
||||||
setcolor("blue")
|
setcolor("blue")
|
||||||
for pp in (Ap, Bp)
|
for pp in (Ap, Bp)
|
||||||
circle(R * pp, pr, :fill)
|
circle(R * pp, pr, :fill)
|
||||||
|
end
|
||||||
|
|
||||||
|
setcolor("black")
|
||||||
|
setdash("dot")
|
||||||
|
line(R * Ap, R * Bp, :stroke)
|
||||||
|
line(Point(0, 0), COMp, :stroke)
|
||||||
|
|
||||||
|
setcolor("purple1")
|
||||||
|
circle(M, pr, :fill)
|
||||||
|
|
||||||
|
setcolor("brown")
|
||||||
|
circle(COMp, pr, :fill)
|
||||||
|
|
||||||
|
finish()
|
||||||
|
|
||||||
|
return nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
setcolor("black")
|
|
||||||
setdash("dot")
|
|
||||||
line(R * Ap, R * Bp, :stroke)
|
|
||||||
line(Point(0, 0), COMp, :stroke)
|
|
||||||
|
|
||||||
setcolor("purple1")
|
|
||||||
circle(M, pr, :fill)
|
|
||||||
|
|
||||||
setcolor("brown")
|
|
||||||
circle(COMp, pr, :fill)
|
|
||||||
|
|
||||||
finish()
|
|
Loading…
Reference in a new issue