Construction of simple objects

Examples

The following objects are native in Pycao, ie. they can be defined with one or two lines of code. We shall see in the next chapters how to intersect, move, link them... to get the desired 3D-scene starting from these objects.

../../../../_images/someObjects.png
grayGround=plane(Z,origin).colored('Gray' ) # a plane with normal the vector Z=vector(0,0,1) containing the origin
# The possible colors are the colors described in colors.inc in povray or a rgb color.

brownCube=Cube(1,2,2).colored("Brown") # The two opposite corners of the cube are origin and point(1,2,2)
brownCube.move_at(origin-2*X-Y) # the center of the brownCube is moved at this position

closedPinkCylinder=Cylinder(start=origin+2*Y,end=origin+2*Y+.4*Z,radius=0.5).colored('SpicyPink')

axis=Segment(point(0,-4,0),point(0,-4,1))
infiniteYellowCylinder=ICylinder(axis,0.5).colored('Yellow') #an infinite cylinder of radius 0.5

redSphere=Sphere(origin+.8*Z,.8).colored('Red') #arguments=center and radius

silverWasher=Washer(point(3,3,0),point(3,3,0.3),.3,0.15).colored('Silver') #arguments; start,end,externalRadius,internalRadius

blueOpenCylinder=Cylinder(start=origin+2*Y,end=origin+2*Y+0.3*Z,radius=0.5,booleanOpen=True) # a vertical Cylinder
blueOpenCylinder.colored('Blue')
blueOpenCylinder.translate(-4*X)

yellowTorus=Torus(0.5,0.1,Z,origin)
yellowTorus.name="Torus"
p1=point(-2,0,0)
p2=point(0,3,0)
yellowTorus.sliced_by(p1,p2,acute=False).colored("Yellow").move_at(-2,3.5,0.5)

r=0.2
curve=Polyline([origin,2*Y+Z,Y+Z,Y+2*Z,-3*Y+Z])
cyanLathe=Lathe(curve).colored("Cyan").move(Map.affine(r*X,r*Y,r*Z,origin+2*X+1.4*Y))

r=0.2
curve=BezierCurve([origin,2*Y+Z,Y+Z,Y+2*Z])
orangeLathe=Lathe(curve).colored("Orange").move(Map.affine(r*X,r*Y,r*Z,origin+4*X))

r=0.15
curve=PiecewiseCurve.fromInterpolation([origin+Y,3*Y+Z,2*Y+Z,Y+Z,Z,-1*Y+2*Z],closedCurve=True)
bronzeLathe=Lathe.fromPiecewiseCurve(curve).colored("Bronze").move(Map.affine(r*X,r*Y,r*Z,origin-4*X))

p0=origin;
p1=p0-X+Y;p2=p1+X+Y;p3=p2+X-Y;
i=1.4
curve4=PiecewiseCurve.fromInterpolation([origin,p1,p2,p3,origin],closedCurve=True)
curve7=PiecewiseCurve.fromInterpolation([p2,p3,origin,p1,p2],closedCurve=True).scale(i,i,i).translate(1.7*Z)
# The union of segments [curve7(t),curve4(t)]:
HunterGreenRuledSurface=RuledSurface(curve7,curve4).colored("HuntersGreen").translate(-3.2*Y+3*X)

violetCone=Cone(origin,origin+2*Z,.6,2 ).colored("Violet").translate(-4.5*X-4*Y)# arguments: start,end,radius1,radius2


camera=Camera()
camera.file="someObjects.pov"
camera.filmAllActors=False
camera.location=origin+7*Y+3.2*Z
camera.zoom(0.2)
camera.lookAt=closedPinkCylinder.center
camera.povraylights="light_source {<-2,0,6.8> color White " + "}\n\n"
camera.actors=[grayGround,brownCube,closedPinkCylinder,infiniteYellowCylinder,violetCone,
              redSphere,silverWasher,blueOpenCylinder,yellowTorus,cyanLathe,orangeLathe,bronzeLathe,HunterGreenRuledSurface]
camera.shoot # takes the photo, ie. creates the povray file, and stores it in camera.file
camera.show # show the photo, ie calls povray.