How to plot a parallelepiped ?

91 views (last 30 days)
Arvind Sridharan
Arvind Sridharan on 19 Oct 2017
Answered: Walter Roberson on 19 Oct 2017
how to plot a parallelepiped or any 3d shape and perform transformation about the xy plane

Answers (1)

Walter Roberson
Walter Roberson on 19 Oct 2017
I recommend constructing a list of vertexes, and a list of face connections (information on how the vertices connect), and use patch() to draw them. Be sure to be consistent on the order of vertices so that whether a side is inside or outside can be determined for lighting purposes. I keep forgetting the convention but my memory is whispering counter-clockwise.
From there, rotation and reflection and sheer can be done by updating the vertex information. However other ways can be more convenient.
One approach is to create a hgtransform and use it as the parent object for the graphic object to be transformed. Then you can set the hgtransform transform matrix property or you can use makehgtform to create a the matrix.
hgtransform group can be used to transform even "flat" graphics objects such as images or such as to move contour plots in 3 space.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!