%圆和椭圆都是0到360°极角乘上极径来控制的图形
%当x,y方向极径相同时画出的就是圆
%当x,y方向极径不同时画出的就是椭圆
%圆心(x0,y0);半径(a,b);
%旋转可以有两种方式:
%1、仅改变角度旋转,那么图形形状会发生改变
%2、利用坐标轴旋转原理,图形形状不会改变
clear;
% the center of circle/ellipse
x0=0;
y0=0;
theta=0:pi/100:2*pi; % angle:0 to 2*pi
a=10; %
radius of X axis
b=5; % radius
of Y axis
% parametric expression of circle/ellipse
x=a*cos(theta)+x0;
y=b*sin(theta)+y0;
figure;plot(x,y);axis([-15 15 -15 15]);
%1st kind rotation
% the radius will have a clockwise rotation of lamda(angle)
% but the circle/ellipse also will be changed
% when lamda=n*pi/2,the plot will become a line
lamda=pi/4;
x1=a*cos(theta+lamda)+x0;
y1=b*sin(theta)+y0;
figure;plot(x1,y1);axis([-15 15 -15 15]);
%2nd kind rotation
% how to keep the shape of circle/ellipse when rotating axis?
% consider axis rotation relationship
% the shape will not be changed using this method
x2=x*cos(lamda)+y*sin(lamda);
y2=-x*sin(lamda)+y*cos(lamda);
figure;plot(x2,y2);axis([-15 15 -15 15]);