THETA=linspace(0,2*pi,NOP);##CONTINUE##
RHO=ones(1,NOP)*radius;
[X,Y] = pol2cart(THETA,RHO);
X=X+center(1);
Y=Y+center(2);
H=plot(X,Y,style);
axis square;
照猫画虎,来段python的,可惜pylab没有做实pol2cart这个函数,没办法,照着思路自己来吧:
用linspace产生0-2*pi的连续角度,然后计算x,y,最后加上圆心坐标,再给plot就行了.
def myCircle(center,radius,NOP=100):
theta = linspace(0,2*pi,NOP)
x=radius * cos(theta) + center[0]
y=radius * sin(theta) + center[1]
return plot(x,y)
No comments :
Post a Comment