Author: Batmath

u = 0 (slider from 0 to 10, step 0.1)
A = (1, -1)
A1 = (2, -1)
A2 = (1, -2)
a_2 = Ray(A, A1)
b_2 = Ray(A, A2)
B = Point(a_2)
D = Point(b_2)
c_2 = OrthogonalLine(B, a_2)
d_2 = OrthogonalLine(D, b_2)
C = Intersect(c_2, d_2)
rett, a, b, c, d = Polygon(A, B, C, D)
per = Perimeter(rett)
t: u per / 10
Esua: t ≥ 0 ∧ t ≤ a
Esub: t > a ∧ t ≤ a + b
Esuc: t > a + b ∧ t ≤ a + b + c
Esud: t > a + b + c ∧ t ≤ per
E = If(Esua, (t + 1, -1), If[Esub, (x(B), -1 - t + a), If[Esuc, (1 - t + a + b + c, y(C)), If[Esud, (1, t - 1 - per)]]])
el = Segment(A, E)
P: (t, el)
F = Point(rett)
el1 = Segment(A, F)
e = OrthogonalLine(F, a)
Fa = Intersect(e, a)
f = OrthogonalLine(F, d)
Fb = Intersect(b, f)
Fc = Intersect(e, c)
Fd = Intersect(f, d)
Fsua: F ≟ Fa
Fsub: F ≟ Fb
Fsuc: F ≟ Fc
Fsud: F ≟ Fd
w = If(Fsua, Distance[F, A], If[Fsub, Distance[F, B] + a, If[Fsuc, Distance[F, C] + a + b, If[Fsud, Distance[F, D] + a + b + c]]])
Q: (w, el1)
loc1 = Locus(Q, F)