本文整理汇总了Python中simple.circle函数的典型用法代码示例。如果您正苦于以下问题:Python circle函数的具体用法?Python circle怎么用?Python circle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了circle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawnObject
def drawnObject(points,mode='point'):
"""Return the geometric object resulting from draw2D points"""
minor = None
if '_' in mode:
mode,minor = mode.split('_')
closed = minor=='closed'
if mode == 'point':
return points
elif mode == 'polyline':
return PolyLine(points,closed=closed)
elif mode == 'curve' and points.ncoords() > 1:
curl = obj_params.get('curl',None)
closed = obj_params.get('closed',None)
return BezierSpline(points,curl=curl,closed=closed)
elif mode == 'nurbs':
degree = obj_params.get('degree',None)
if points.ncoords() <= degree:
return None
closed = obj_params.get('closed',None)
return NurbsCurve(points,degree=degree,closed=closed)
elif mode == 'circle' and points.ncoords() % 3 == 0:
R,C,N = triangleCircumCircle(points.reshape(-1,3,3))
circles = [circle(r=r,c=c,n=n) for r,c,n in zip(R,C,N)]
if len(circles) == 1:
return circles[0]
else:
return circles
else:
return None
示例2: askCurve
def askCurve():
default = "Angle"
res = askItems([("curve_type", default, "radio", ["Circle", "Angle"]), ("closed", False), ("circle_npts", 6)])
if not res:
exit()
clear()
globals().update(res)
if curve_type == "Circle":
circle = simple.circle(a1=360.0 / circle_npts)
draw(circle, color="magenta")
pts = circle[:, 0]
elif curve_type == "Angle":
F = Formex(simple.pattern("41"))
draw(F, color="magenta")
pts = F.coords.reshape(-1, 3)
clear()
drawNumbers(pts)
print "Number of points: %s" % len(pts)
print "POLY"
PL = PolyLine(pts, closed=closed)
d = PL.directions()
dm = PL.avgDirections()
# w = PL.doubles()+1
# print PL.endOrDouble()
curve = BezierSpline(pts, closed=closed)
draw(curve.approx(100), color="red")
zoomAll()
示例3: askCurve
def askCurve():
default = 'Angle'
res = askItems([('curve_type',default,'radio',['Circle','Angle']),('closed',False),('circle_npts',6)])
if not res:
exit()
clear()
globals().update(res)
if curve_type == 'Circle':
circle = simple.circle(a1=360./circle_npts)
draw(circle,color='magenta')
pts = circle[:,0]
elif curve_type == 'Angle':
F = Formex(simple.pattern('41'))
draw(F,color='magenta')
pts = F.coords.reshape(-1,3)
clear()
drawNumbers(pts)
print "Number of points: %s"%len(pts)
print "POLY"
PL = PolyLine(pts,closed=closed)
d = PL.directions()
dm = PL.avgDirections()
#w = PL.doubles()+1
#print PL.endOrDouble()
curve = BezierSpline(pts,closed=closed)
draw(curve.approx(100),color='red')
zoomAll()
示例4: run
def run():
clear()
linewidth(2)
flat()
F = Formex([[[1.,0.,0.]],[[1.,1.,0.]]]).rosette(4,90.)
draw(F)
drawNumbers(F)
zoomAll()
setDrawOptions(bbox=None)
showDoc()
pts = F.coords.reshape(-1,3)
draw(simple.circle(2,4),color=yellow,linewidth=4)
for degree,c in zip(range(1,4),[black,red,green]):
N = NurbsCurve(pts,degree=degree,closed=True)
draw(N,color=c)
drawThePoints(N,16,color=c)
for w,c in zip([sqrt(2.),sqrt(2.)/2.,0.25,0.],[blue,cyan,magenta,white]):
wts = array([ 1., w ] * 4).reshape(8,1)
pts4 = Coords4(pts)
pts4.deNormalize(wts)
pts4 = Coords4(concatenate([pts4,pts4[:1]],axis=0))
N = NurbsCurve(pts4,degree=2,closed=False,blended=False)
draw(N,color=c)
drawThePoints(N,16,color=c)
示例5: __init__
def __init__(self,lw=2,mm=0.75,hm=0.85,mh=0.7,hh=0.6, sh=0.9):
"""Create an analog clock."""
self.linewidth = lw
self.circle = simple.circle(a1=2.,a2=2.)
radius = Formex(pattern('2'))
self.mainmark = radius.divide([mm,1.0])
self.hourmark = radius.divide([hm,1.0])
self.mainhand = radius.divide([0.0,mh])
self.hourhand = radius.divide([0.0,hh])
if sh > 0.0:
self.secshand = radius.divide([0.0,sh])
else:
self.secshand = None
self.hands = []
self.timer = None
示例6: drawCircles
def drawCircles(sections,ctr,diam):
"""Draw circles as approximation of Formices."""
circle = simple.circle().rotate(-90,1)
cross = Formex(simple.Pattern['plus']).rotate(-90,1)
circles = []
n = len(sections)
for i in range(n):
C = cross.translate(ctr[i])
B = circle.scale(diam[i]/2).translate(ctr[i])
S = sections[i]
clear()
draw(S,view='left',wait=False)
draw(C,color='red',bbox=None,wait=False)
draw(B,color='blue',bbox=None)
circles.append(B)
return circles
示例7: circle_stl
def circle_stl():
"""Draw circles as approximation of the STL model."""
global sections,ctr,diam,circles
import simple
circle = simple.circle().rotate(-90,1)
cross = Formex(simple.Pattern['plus']).rotate(-90,1)
circles = []
n = len(sections)
for i in range(n):
C = cross.translate(ctr[i])
B = circle.scale(diam[i]/2).translate(ctr[i])
S = sections[i]
print C.bbox()
print B.bbox()
print S.bbox()
clear()
draw(S,view='left',wait=False)
draw(C,color='red',bbox=None,wait=False)
draw(B,color='blue',bbox=None)
circles.append(B)
示例8: ask
# MESH PARAMETERS
el = 20 #number of elements along the length
etb = 2 #number of elements over half of the thickness of the body
ehb = 5 #number of elements over half of the height of the body
etf = 5 #number of elements over the thickness of the flange
ewf = 8 #number of elements over half of the width of the flange
er = 6 #number of elements in the circular segment
Body = simple.rectangle(etb,ehb,tw/2.,h/2.-tf-r)
Flange1 = simple.rectangle(er/2,etf-etb,tw/2.+r,tf-tw/2.).translate([0.,h/2.-(tf-tw/2.),0.])
Flange2 = simple.rectangle(ewf,etf-etb,b/2.-r-tw/2.,tf-tw/2.).translate([tw/2.+r,h/2.-(tf-tw/2.),0.])
Flange3 = simple.rectangle(ewf,etb,b/2.-r-tw/2.,tw/2.).translate([tw/2.+r,h/2.-tf,0.])
c1a = simple.line([0,h/2-tf-r,0],[0,h/2-tf+tw/2,0],er/2)
c1b = simple.line([0,h/2-tf+tw/2,0],[tw/2+r,h/2-tf+tw/2,0],er/2)
c1 = c1a + c1b
c2 = simple.circle(90./er,0.,90.).reflect(0).scale(r).translate([tw/2+r,h/2-tf-r,0])
Filled = simple.connectCurves(c2,c1,etb)
Quarter = Body + Filled + Flange1 + Flange2 + Flange3
Half = Quarter + Quarter.reflect(1).reverse()
Full = Half + Half.reflect(0).reverse()
Section = Full.toMesh()
clear()
draw(Section,color=red)
#exit()
#pause()
method = ask("Choose extrude method:",['Cancel','Sweep','Connect','Extrude','ExtrudeQuadratic','Revolve','RevolveLoop'])
import timer
示例9: circle_example
def circle_example():
return simple.circle(5.,5.)
示例10: draw_circles
def draw_circles(circles, color=red):
for r, c, n in circles:
C = simple.circle(r=r, n=n, c=c)
draw(C, color=color)
示例11: run
def run():
# GEOMETRICAL PARAMETERS FOR HE200B wide flange beam
h = 200. #beam height
b = 200. #flange width
tf = 15. #flange thickness
tw = 9. #body thickness
l = 400. #beam length
r = 18. #filling radius
# MESH PARAMETERS
el = 20 #number of elements along the length
etb = 2 #number of elements over half of the thickness of the body
ehb = 5 #number of elements over half of the height of the body
etf = 5 #number of elements over the thickness of the flange
ewf = 8 #number of elements over half of the width of the flange
er = 6 #number of elements in the circular segment
Body = simple.rectangle(etb,ehb,tw/2.,h/2.-tf-r)
Flange1 = simple.rectangle(er/2,etf-etb,tw/2.+r,tf-tw/2.).translate([0.,h/2.-(tf-tw/2.),0.])
Flange2 = simple.rectangle(ewf,etf-etb,b/2.-r-tw/2.,tf-tw/2.).translate([tw/2.+r,h/2.-(tf-tw/2.),0.])
Flange3 = simple.rectangle(ewf,etb,b/2.-r-tw/2.,tw/2.).translate([tw/2.+r,h/2.-tf,0.])
c1a = simple.line([0,h/2-tf-r,0],[0,h/2-tf+tw/2,0],er/2)
c1b = simple.line([0,h/2-tf+tw/2,0],[tw/2+r,h/2-tf+tw/2,0],er/2)
c1 = c1a + c1b
c2 = simple.circle(90./er,0.,90.).reflect(0).scale(r).translate([tw/2+r,h/2-tf-r,0])
Filled = simple.connectCurves(c2,c1,etb)
Quarter = Body + Filled + Flange1 + Flange2 + Flange3
Half = Quarter + Quarter.reflect(1).reverse()
Full = Half + Half.reflect(0).reverse()
Section = Full.toMesh()
clear()
draw(Section,color=red)
#return
#pause()
method = ask("Choose extrude method:",['Cancel','Sweep','Connect','Extrude','ExtrudeQuadratic','Revolve','RevolveLoop'])
import timer
t = timer.Timer()
if method == 'Sweep':
L = simple.line([0,0,0],[0,0,l],el)
x = concatenate([L.coords[:,0],L.coords[-1:,1]])
path = curve.PolyLine(x)
Beam = Section.sweep(path,normal=[0.,0.,1.],upvector=[0.,1.,0.])
elif method == 'Connect':
Section1 = Section.trl([0,0,l])
Beam = Section.connect(Section1,el)
elif method == 'Extrude':
Beam = Section.extrude(el,step=l/el,dir=2)
elif method == 'ExtrudeQuadratic':
Section = Section.convert('quad9')
Beam = Section.extrude(el,step=l/el,dir=2,degree=2)
elif method == 'Revolve':
Beam = Section.revolve(el,axis=1,angle=60.,around=[-l,0.,0.])
elif method == 'RevolveLoop':
Beam = Section.revolve(el,axis=1,angle=240.,around=[-l,0.,0.],loop=True)
else:
return
print("Computing: %s seconds" % t.seconds())
#print Beam.prop
#print Beam.elems.shape
t.reset()
clear()
#draw(Beam,color='red',linewidth=2)
draw(Beam.getBorderMesh(),color='red',linewidth=2)
print("Drawing: %s seconds" % t.seconds())
export({'Beam':Beam})
示例12: createGeometry
def createGeometry():
global F
# Construct a triangle of an icosahedron oriented with a vertex in
# the y-direction, and divide its edges in n parts
n = 6
# Add a few extra rows to close the gap after projection
nplus = n+3
clear()
# Start with an equilateral triangle in the x-y-plane
A = simple.triangle()
A.setProp(1)
draw(A)
# Modular size
a,b,c = A.sizes()
GD.message("Cell width: %s; height: %s" % (a,b))
# Create a mirrored triangle
B = A.reflect(1)
B.setProp(2)
draw(B)
# Replicate nplus times in 2 directions to create triangular pattern
F = A.replic2(1,nplus,a,-b,0,1,bias=-a/2,taper=1)
G = B.replic2(1,nplus-1,a,-b,0,1,bias=-a/2,taper=1)
clear()
F += G
draw(F)
# Get the top vertex and make it the origin
P = F[0,-1]
draw(Formex([P]),bbox=None)
F = F.translate(-P)
draw(F)
# Now rotate around the x axis over an angle so that the projection on the
# x-y plane is an isosceles triangle with top angle = 360/5 = 72 degrees.
# The base angles thus are (180-72)/2 = 54 degrees.
# Ratio of the height of the isosceles triangle over the icosaeder edge length.
c = 0.5*tand(54.)
angle = arccos(tand(54.)/sqrt(3.))
GD.message("Rotation Ratio: %s; Angle: %s, %s" % (c,angle,angle/rad))
F = F.rotate(angle/rad,0)
clear()
draw(F,colormap=['black','magenta','yellow','black'])
# Project it on the circumscribing sphere
# The sphere has radius ru
golden_ratio = 0.5 * (1. + sqrt(5.))
ru = 0.5 * a * sqrt(golden_ratio * sqrt(5.))
GD.message("Radius of circumscribed sphere: %s" % ru)
ru *= n
C = [0.,0.,-ru]
F = F.projectOnSphere(ru,center=C)
draw(F)
hx,hy,h = F.sizes()
GD.message("Height of the dome: %s" % h)
# The base circle goes through bottom corner of n-th row,
# which will be the first point of the first triangle of the n-th row.
# Draw the point to check it.
i = (n-1)*n/2
P = F[i][0]
draw(Formex([P]),marksize=10,bbox=None)
# Get the radius of the base circle from the point's coordinates
x,y,z = P
rb = sqrt(x*x+y*y)
# Give the base points a z-coordinate 0
F = F.translate([0.,0.,-z])
clear()
draw(F)
# Draw the base circle
H = simple.circle().scale(rb)
draw(H)
# Determine intersections with base plane
P = [0.,0.,0.]
N = [0.,0.,1.]
newprops = [ 5,6,6,None,4,None,None ]
F = F.cutAtPlane(P,N,newprops=newprops,side='+',atol=0.0001)
#clear()
draw(F)
# Finally, create a rosette to make the circle complete
# and rotate 90 degrees to orient it like in the paper
clear()
F = F.rosette(5,72.).rotate(90)
def cutOut(F,c,r):
#.........这里部分代码省略.........
示例13: circle_example
def circle_example():
H = simple.circle(5.,5.)
draw(H)
return sectionChar(H)
示例14: length
L = length(N)
#print L
S = L / (length(A)*length(B))
ANG = arcsin(S.clip(min=-1.0,max=1.0))
N = N/column_stack([L])
if not rad:
ANG *= 180./pi
return (ANG,N)
# Test
linewidth(1)
drawtimeout = 1
for i in [3,4,5,6,8,12,20,60,180]:
#print "%s points" % i
clear()
draw(circle(360./i,360./i),bbox=None)
clear()
draw(circle(360./i,2*360./i),bbox=None)
clear()
draw(circle(360./i,360./i,180.),bbox=None)
# Example of the use
clear()
n = 40
h = 0.5
line = Formex(pattern('1'*n)).scale(2./n).translate([-1.,0.,0.])
curve = line.bump(1,[0.,h,0.],lambda x: 1.-x**2)
curve.setProp(1)
draw(line)
draw(curve)
示例15: clear
clear()
linewidth(2)
flat()
F = Formex([[[1.,0.,0.]],[[1.,1.,0.]]]).rosette(4,90.)
draw(F)
drawNumbers(F)
zoomAll()
setDrawOptions(bbox=None)
showDescription()
pts = F.coords.reshape(-1,3)
draw(simple.circle(2,4),color=yellow,linewidth=4)
for degree,c in zip(range(1,4),[black,red,green]):
N = NurbsCurve(pts,degree=degree,closed=True)
draw(N,color=c)
drawThePoints(N,16,color=c)
for w,c in zip([sqrt(2.),sqrt(2.)/2.,0.25,0.],[blue,cyan,magenta,white]):
wts = array([ 1., w ] * 4).reshape(8,1)
pts4 = Coords4(pts)
pts4.deNormalize(wts)
pts4 = Coords4(concatenate([pts4,pts4[:1]],axis=0))
N = NurbsCurve(pts4,degree=2,closed=False,blended=False)
draw(N,color=c)
drawThePoints(N,16,color=c)