How can I plot a 3D rectangle and use hgtransform?

5 views (last 30 days)
I would like to plot a 3D rectangle, then transform it using hgtransform and plot the result. I have been able to do this with a cylinder, but haven't been able to use a rectangle.
Here is what I used to draw the original cylinder:
[cylX, cylY, cylZ] = cylinder(0.5);
hgTransformArray = surface(cylX, cylY, cylZ);
hgTransform = hgtransform('Parent', graphAxes);
set(hgTransformArray, 'Parent', hgTransform);
drawnow;
What can I used in place of the cylinder function to get a 3D rectangle? Thanks, any help is appreciated!

Answers (1)

Matt J
Matt J on 3 Jun 2014
Something like the following perhaps
N=10;
[X,Y,Z]=ndgrid(linspace(-1,1,N));
idx=abs(X)<1 & abs(Y)<1 & abs(Z)<1;
X(idx)=[]; Y(idx)=[]; Z(idx)=[];
hgTransformArray=scatter3(X(:),Y(:),Z(:));
axis([-1.5 1.5 -1.5 1.5 -1.5 1.5])
hgTransform = hgtransform('Parent', gca);
set(hgTransformArray, 'Parent', hgTransform);
drawnow;
You could also use the following to rotate the X,Y,Z data
With this, the data doesn't need to be plotted in order to be rotated/transformed
  1 Comment
keagan
keagan on 3 Jun 2014
Hello guys
I have a question related to hough transform for detecting a square.
With regards to line detection for a square, using hough transform, I have detected the lines of the square but I need your help with something. How do I say in matlab code that the 2 lines on the rows is perpedicular and the lines on the columns also are and also to say the angles are 90 degrees at the edges to make it a square.
please advice thanks

Sign in to comment.

Categories

Find more on Graphics Performance 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!