1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2025-09-04 09:12:35 +00:00

Added the method center_of_mass

This commit is contained in:
MoBit 2021-12-03 14:16:35 +01:00
parent 02a6dd9489
commit 27591af18b
3 changed files with 56 additions and 15 deletions

View file

@ -1,17 +1,6 @@
using Luxor
using ReCo: restrict_coordinate
##
function project(x, L)
φ = (x + L) * π / L
return Point(cos(φ), -sin(φ))
end
function project_back(θ, L)
return θ * L / π - L
end
using ReCo: restrict_coordinate, project_to_unit_circle, project_back_from_unit_circle
##
@ -26,14 +15,20 @@ A = -0.9 * L
B = 0.65 * L
pr = 0.03 * L
Ap = project(A, L)
Bp = project(B, L)
Ap_array = project_to_unit_circle(A, L)
Bp_array = project_to_unit_circle(B, L)
for p in (Ap_array, Bp_array)
p[2] *= -1
end
Ap = Point(Ap_array)
Bp = Point(Bp_array)
M = R * ((Ap + Bp) / 2)
θ = atan(-M[2], M[1])
COM = restrict_coordinate(project_back(θ, L); l=L)
COM = project_back_from_unit_circle(θ, L)
COMp = R * Point(cos(θ), -sin(θ))
##