Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hmax = 2;
- Cost[h_, y_, \[Lambda]_] :=
- With[{p1 = {-1, 0}, p2 = {-0.8, y}, p3 = {0.8, h - y}, p4 = {1, h}},
- Norm[p2 - p1] + Norm[p3 - p2] + Norm[p4 - p3] +
- \[Lambda] Norm[p3 - p2]
- ];
- Manipulate[
- Block[{yo, n},
- yo = yt /. (Minimize[Cost[h, yt, \[Lambda]], yt][[2]]);
- With[{p1 = {-1, 0}, p2 = {-0.8, y}, p3 = {0.8, h - y}, p4 = {1, h},
- p2o = {-0.8, yo}, p3o = {0.8, h - yo}},
- n = Sin[VectorAngle[p2o - p1, {-1, 0}]]/
- Sin[VectorAngle[p3o - p2o, {-1, 0}]];
- Graphics[{
- GrayLevel[0.7],
- Rectangle[{-1, -0.5}, {1, hmax + 0.5}],
- GrayLevel[0.5],
- Rectangle[{-0.8, -0.5}, {0.8, hmax + 0.5}],
- PointSize[Large], Blue, Point[p1], Red, Point[p4],
- (*Black,Point[p2],Point[p3],Line[{p1,p2,p3,p4}],*)
- Dashed,
- Purple, Point[p2o], Point[p3o], Line[{p1, p2o, p3o, p4}]
- }]
- ]
- ],
- {{\[Lambda], 1}, 0, 5}
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement