How to expand/shrink 3D Polygon in 2D directions (X-Y)?
13 views (last 30 days)
Show older comments
Faez Alkadi on 10 Dec 2017
Edited: Faez Alkadi on 7 Apr 2018
I have a xyz=17x3 array which forms an open square shape. I want to expand the shape (inside or outside only) with respect to xy_directions only and get a new array xy=17x2 . So I can add the third column (Z) to the new array xy from the original array xyz and end up with a third array XYZ1=17x3. where * XYZ1=[xy(:,1),xy(:,2),xyz(:,3)]*. In this case, I end up with expanded shape in xy_directions but keep (Z) fixed.(which I'm wishing for)
I tried the function expandPolygon from geom2d. But the output array has some rows filled with (Inf) instead of numbers, even though it has the same length as original array xyz.
Hope you can help me with that Thank you so much.
Matt J on 10 Dec 2017
Edited: Matt J on 10 Dec 2017
I may not fully understand the question. You have a square floating in 3D space. You want to expand or contract the square within the same plane that it exists now? If so, then you can simply do (assuming you have R2016b or higher) as follows:
where c is an expansion or contraction factor. For example, with c=1.5, you would get the orange dots below.
Matt J on 11 Dec 2017
Edited: Matt J on 11 Dec 2017
To map everything into 2D
Now you can use the geom2D toolkit freely on the 2D data set, xy to generate xy2. As we've discussed, remove redundant colinear points to avoid Infs. To map xy2 back to the original 3D coordinate system,
XYZ1= xy2 * V(:,1:2).' + mu ;
Matt J on 13 Dec 2017
Edited: Matt J on 13 Dec 2017
The attached file might be close to what you want. When I do
on your last xyz data set, I get the orange dots below,
Find more on Computational Geometry in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!