patching the area between multiple points
古いコメントを表示
ive been using the patch() function for filling in the area between points. however patch needs the right order of points in order to work as expected.
im working with a function that delivers a points on a plane and i want to fill in the space between the points. depending on the angle of the plane the points are in different positions relative to eath other. so one fixed order for my path() functions doesnt work for all angles.
i need a function that takes points and fills the space in between regardless of the order they are given in.
(for extra context: the points correspond to the orthogonal projection of the vertices of a floating cuboid, changing the angle of the plane changes the "shadow" of the cuboid on the plane. i want that shadow to be filled in.)
回答 (1 件)
(for extra context: the points correspond to the orthogonal projection of the vertices of a floating cuboid, changing the angle of the plane changes the "shadow" of the cuboid on the plane. i want that shadow to be filled in.)
The orthogonal projection of a cuboid is convex, but some of the projected vertices of the cuboid will not in general be on the convex boundary of the projected region, so we need to exclude those. This is easily done with convhull
k=convhull(x,y);
patch(x(k),y(k))
10 件のコメント
Patrick Daly
2022 年 12 月 4 日
You should re-express the points in a 2D coordinate system (xp,yp) attached to the plane. Then,
k=convhull(xp,yp);
patch(x(k),y(k),z(k))
Patrick Daly
2022 年 12 月 4 日
Matt J
2022 年 12 月 4 日
Yes, did you try it?
Patrick Daly
2022 年 12 月 4 日
Patrick Daly
2022 年 12 月 4 日
Then you can get 2D coordinates by doing M'*x.
Incidentally, you shouldn't be using Gram-Schmidt as it is not a stable algorithm in general. Use orth(), qr(), or svd().
Patrick Daly
2022 年 12 月 10 日
カテゴリ
ヘルプ センター および File Exchange で Polygons についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
