slope to a circle

3 次查看(过去 30 天)
reza
reza 2014-1-2
hi, how can i give slope two a circle using the code below,
if true
% code
r=1
teta=-pi:0.01:pi
x=r*cos(teta);
y=r*sin(teta);
z=zeros(1,numel(x));
plot3(x,y,z);
hold on
end
  1 个评论
Image Analyst
Image Analyst 2014-1-2
What do you mean by slope? Do you mean that you don't want the z values to all be the same so that it is parallel with the x-y plane? That you want the circle tilted/slanted so that it has a variety of z values?

请先登录,再进行评论。

回答(2 个)

cr
cr 2014-1-2
编辑:cr 2014-1-2
For you. Cheers.
function coordinates = arc(C,R,inplane,normal,t)
% ARC function generates coordinates to draw a circular arc in 3D
% arc(C,R,inplane,normal,t)
% R - Radius
% C - Centre
% inplane - A vector in plane of the circle
% normal - A vector normal to the plane of the circle
% t - vector of theta. E.g. for a full circle this is 0:0.01:2*pi
% By Chandrakanth R.Terupally
v = cross(normal,inplane);
coordinates = [C(1) + R*cos(t)*inplane(1) + R*sin(t)*v(1);
C(2) + R*cos(t)*inplane(2) + R*sin(t)*v(2);
C(3) + R*cos(t)*inplane(3) + R*sin(t)*v(3)];
end

Image Analyst
Image Analyst 2014-1-2
编辑:Image Analyst 2014-1-2
Try this:
fontSize = 20;
r=1;
theta = linspace(-pi, pi, 90);
x = r * cos(theta);
y = r * sin(theta);
tiltFactor = 1.0;
z = tiltFactor * x;
plot3(x,y,z, 'bo-', 'LineWidth', 2);
hold on
grid on
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
zlabel('Z', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by