How to rotate an Alpha Shape, or points that defines the edge of a 3D shape?

Hello,
I am trying to rotate a 3-D surface which composed of 1000 points defined in space. I turned these points to a surface by using alphashape function.
I tried to rotate with "rotate" function but, I got type error;
Error in rotate (line 59)
t = get(h(i),'type');
Can you suggest me a solution?
For additional information, please ask it.
Thanks in advance, Mücahit

 Accepted Answer

Could you post your code?
Here's a modified version of one of the examples:
[x1, y1, z1] = sphere(24);
x1 = x1(:);
y1 = y1(:);
z1 = z1(:);
x2 = x1+5;
P = [x1 y1 z1; x2 y1 z1];
P = unique(P,'rows');
shp = alphaShape(P,1)
h = plot(shp);
axis vis3d
for i=1:12
rotate(h,[1 1 1],30)
pause(.25)
end

3 Comments

Thank you Mike,
My code as follows;
clc
clear all
[P]=Rock1(15);
as_rock = alphaShape(P(:,1),P(:,2),P(:,3),4);
plot(as_rock,'FaceColor',[218 136 86]./255,'EdgeAlpha',0) %plot the rock
title('Simulated Figure') %create a title
lighting gouraud %lighting
light('Position',[100 -200 50],'Style','local') %light position
axis equal % realistic axes
direction = [1 0 0];
origin = [P(1,1) P(1,2) P(1,3)];
rotate(as_rock,direction,25,origin);
And the Rock1 function as follows;
function [ P ] = Rock1( D ) %input arguments Diameter and returns a defined Rock points with diameter D
x=randn(1000,1); %assign normally distributed random numbers
multi_x1=D/(max(x)-min(x)); %to make its diameter, find its current diameter with max-min function and find its multiplyer
x11= (multi_x1*x); %final x coordinates assigned here
y=randn(1000,1);
multi_y1=D/(max(y)-min(y));
y11=(multi_y1*y);
z=randn(1000,1);
multi_z1=D/(max(z)-min(z));
z11=multi_z1*z;
P = [x11 y11 z11]; %output argument like points on space that defines our rocks
end
Thank you!
Ah, the rotate function wants the handle of the graphics object, not the alphaShape. The graphics object is created by the plot function. So you need something like:
h = plot(as_rock,'FaceColor', ...
...
rotate(h,direction,25,origin)
Thank you my friend :) it worked as I wanted.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!