how to draw a tilted circle?

Hai,
The following code draws a circle in the x-z plane in 3D.
radius=1;
center=[2 4 2];
theta=linspace(0,2*pi);
rho=ones(1,100).*radius;
[x,z]=pol2cart(theta,rho);
x=x+center(1);
z=z+center(3);
y=center(2)*ones(1,length(x));
figure;
h=plot3(x,y,z);
grid on;
axis square;
By default the above circle is vertical in the x-z plane. I need to draw a circle which is inclined or tilted at some angle. How could I do this?
Looking forward for your reply.
BSD

1 Kommentar

Walter Roberson
Walter Roberson am 3 Okt. 2011
Duplicate is at http://www.mathworks.com/matlabcentral/answers/17160-how-to-draw-an-inclined-circle

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 3 Okt. 2011

1 Stimme

You have X-, Y- and Z-coordinates. Now you want to tilt the obejct. This can be done by applying a rotation matrix, e.g. for a rotation around the Z-axis by the angle a :
R = [ cos(a), sin(a), 0; ...
-sin(a), cos(a), 0; ...
0, 0, 1];
This matrix must be multiplied to the array of coordinates. See also: Wiki: Rotation Matrix

4 Kommentare

bsd
bsd am 4 Okt. 2011
The circle is getting tilted, but the location of the circle is changing. I need the circle to tilt at the same location, where it is vertical. What could be done?
BSD
bsd
bsd am 4 Okt. 2011
I meant, something like tilting around the same center, i.e. the face of the circle should tilt or rotate around its center.
http://www.google.co.in/search?hl=en&q=atom&gs_sm=e&gs_upl=2900l3348l0l3711l4l4l0l0l0l0l376l1067l3-3l3l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1143&bih=668&um=1&ie=UTF-8&tbm=isch&source=og&sa=N&tab=wi
Go to the above the link, and see the tilted circles in the structure of the atom, around the same center.
BSD
Walter Roberson
Walter Roberson am 4 Okt. 2011
Generate the circle around (0,0,0), rotate it, and then translate the circle by the coordinates of the new center that you want.
Or if you already have a circle existing and decide later that you want to tilt it, then translate it to (0,0,0), rotate it, and then translate it back.
bsd
bsd am 5 Okt. 2011
It is working. Excellent... Thank you...
BSD

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 3 Okt. 2011

0 Stimmen

The answer hasn't changed since your previous time asking.
If you wish to do it mathematically instead of the way I suggested before, then say as much (at which point I would say, "So, did you read the documentation to find out what that routine actually does ?")

1 Kommentar

Jan
Jan am 3 Okt. 2011
@Walter: Your answer has been complete. I add more details only, because it seems that the OP cannot follow completely.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

bsd
am 3 Okt. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by