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

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!

답변 (1개)

Matt J
Matt J 2014년 6월 3일
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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Object Containers에 대해 자세히 알아보기

질문:

2014년 6월 3일

댓글:

2014년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by