Inicio

v = (2, 0)
P: (4, 35)
vn: (-OrthogonalVector[v])
laberinto = Polygon({(-2, 52), (152, 52), (152, -90), (140, -90), (140, -88), (150, -88), (150, -80), (132, -80), (132, -90), (120, -90), (120, -88), (130, -88), (130, -78), (150, -78), (150, -30), (120, -30), (120, -50), (110, -50), (110, -40), (92, -40), (92, -50), (90, -50), (90, -40), (72, -40), (72, -50), (32, -50), (32, -70), (30, -70), (30, -48), (48, -48), (48, -38), (50, -38), (50, -48), (70, -48), (70, -38), (112, -38), (112, -48), (118, -48), (118, -30), (90, -30), (90, 0), (68, 0), (68, 20), (60, 20), (60, -10), (58, -10), (58, 0), (50, 0), (50, 2), (58, 2), (58, 20), (50, 20), (50, 22), (58, 22), (58, 42), (70, 42), (70, 40), (60, 40), (60, 22), (70, 22), (70, 2), (90, 2), (90, 12), (98, 12), (98, 42), (130, 42), (130, 32), (140, 32), (140, 30), (128, 30), (128, 40), (100, 40), (100, 22), (110, 22), (110, 20), (100, 20), (100, 10), (92, 10), (92, -8), (138, -8), (138, 2), (140, 2), (140, -20), (138, -20), (138, -10), (110, -10), (110, -20), (100, -20), (100, -18), (108, -18), (108, -10), (92, -10), (92, -28), (118, -28), (118, -18), (130, -18), (130, -20), (120, -20), (120, -28), (150, -28), (150, 20), (120, 20), (120, 10), (110, 10), (110, 2), (128, 2), (128, 12), (140, 12), (140, 10), (130, 10), (130, 0), (100, 0), (100, 2), (108, 2), (108, 12), (118, 12), (118, 30), (110, 30), (110, 32), (120, 32), (120, 22), (150, 22), (150, 40), (140, 40), (140, 42), (150, 42), (150, 50), (90, 50), (90, 20), (80, 20), (80, 10), (78, 10), (78, 30), (70, 30), (70, 32), (78, 32), (78, 42), (80, 42), (80, 22), (88, 22), (88, 50), (50, 50), (50, 30), (42, 30), (42, 12), (50, 12), (50, 10), (42, 10), (42, -8), (50, -8), (50, -18), (68, -18), (68, -8), (82, -8), (82, -30), (60, -30), (60, -40), (58, -40), (58, -30), (42, -30), (42, -40), (22, -40), (22, -78), (40, -78), (40, -58), (60, -58), (60, -60), (52, -60), (52, -70), (50, -70), (50, -60), (42, -60), (42, -88), (52, -88), (52, -90), (40, -90), (40, -80), (20, -80), (20, -60), (10, -60), (10, -58), (20, -58), (20, -40), (10, -40), (10, -38), (40, -38), (40, -18), (42, -18), (42, -28), (80, -28), (80, -10), (70, -10), (70, -20), (48, -20), (48, -10), (22, -10), (22, -20), (8, -20), (8, 2), (28, 2), (28, 20), (8, 20), (8, 22), (18, 22), (18, 32), (20, 32), (20, 22), (30, 22), (30, 0), (10, 0), (10, -18), (20, -18), (20, -8), (40, -8), (40, 40), (42, 40), (42, 32), (48, 32), (48, 50), (0, 50), (0, 32), (8, 32), (8, 42), (30, 42), (30, 30), (28, 30), (28, 40), (10, 40), (10, 30), (0, 30), (0, 12), (20, 12), (20, 10), (0, 10), (0, -28), (30, -28), (30, -18), (32, -18), (32, -30), (0, -30), (0, -48), (10, -48), (10, -50), (0, -50), (0, -98), (30, -98), (30, -90), (10, -90), (10, -68), (12, -68), (12, -88), (32, -88), (32, -98), (70, -98), (70, -78), (80, -78), (80, -68), (82, -68), (82, -88), (100, -88), (100, -90), (80, -90), (80, -80), (72, -80), (72, -98), (108, -98), (108, -80), (90, -80), (90, -60), (72, -60), (72, -70), (62, -70), (62, -90), (60, -90), (60, -80), (50, -80), (50, -78), (60, -78), (60, -68), (70, -68), (70, -58), (80, -58), (80, -48), (82, -48), (82, -58), (100, -58), (100, -48), (102, -48), (102, -58), (130, -58), (130, -38), (142, -38), (142, -70), (122, -70), (122, -80), (120, -80), (120, -70), (100, -70), (100, -68), (140, -68), (140, -40), (132, -40), (132, -60), (92, -60), (92, -78), (110, -78), (110, -98), (152, -98), (152, -100), (-2, -100)})
r2 = Ray(P, P + vn)
r1 = Ray(P, P + v)
t = 0.303 (slider from 0 to 1, step 0.001)
pA = RemoveUndefined({Intersect[r1, laberinto]})
pD = RemoveUndefined({Intersect[r2, laberinto]})
dA = Sequence(Distance[P, Element[pA, k]], k, 1, Length[pA])
dD = Sequence(Distance[P, Element[pD, k]], k, 1, Length[pD])
Pa = Element(pA, IndexOf[Min[dA], dA])
Pd = Element(pD, IndexOf[Min[dD], dD])
dPA = Distance(P, Pa)
dPD = Distance(P, Pd)