# Solids of revolution

Solids of revolution carry a special axis. They may be put at the right position using the position of their axis.

We illustrate in the code example below how to proceed to put a key in a key hole. The key is not a solid of revolution, but there is an axis that we naturally see on the key, so it is easy to handle the key as a solid of revolution.

First, we declare an axis for the hole, and we ask the key (which has an axis by default since this is built from a cylinder ) to be screwed into the hole.

The parameters of the screwing are adjusted thanks to two parameters adjustAlong and adjustAround, both of which are a pair of points.

The depth of the screwing is governed by adjustAlong. In the example below, adjustAlong=[endKey, endHole]. Pycao screws/unscrews until the 2 points are on the same plane orthogonal to the screwing axis.

Then there is an adjustment by a rotation around the axis. In the example, adjustAround=[topHandle,aPointOnTheRight]. This puts the highest point topHandle of the key handle “on the right”. The key is turned on itself and we may imagine mentally that the point topHandle on the key moves when we turn the key. The key is rotated until [topHandle,aPointOnTheRight] is a line going through the axis of rotation.

g=plane(Z,origin-Z).colored("Grey")
# The construction of the lock with the hole inside it
lock=Cube(1,.2,1)
endHole=point(.5,.2,.5)
aPointOnTheRight=point(10,.2,.5)
toCut=ICylinder(Segment(origin,origin+Y),.2)
lock.move_at(origin).colored("Brown").amputed_by(toCut)

# The construction of the key with its handle
endKey=origin+3*X
startKey=origin+4*X
key=Cylinder(startKey,endKey,.2).colored("Bronze")
handle=Cylinder(origin+4*X-.05*Y,origin+4*X+.05*Y,.3).colored("Bronze").glued_on(key)
topHandle=origin+4*X+.3*Z

# We take a first photo
camera=Camera()
camera.file="keyHole.pov"
camera.filmAllActors=False
camera.location=origin-7*Y+3.2*Z
camera.zoom(0.3)
camera.lookAt=origin
camera.actors=[g,key,lock]
camera.shoot # takes the photo, ie. creates the povray file, and stores it in camera.file
camera.show # show the photo, ie calls povray.

#  The key is put in the hole and an other photo is shot