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

조회 수: 9 (최근 30일)
Alissa
Alissa 2014년 6월 3일
댓글: keagan 2014년 6월 3일
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
keagan
keagan 2014년 6월 3일
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

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

카테고리

Help CenterFile Exchange에서 Object Containers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by