The piston & cylinder case.

There are 4 objects in the flow.

piston.dat, block.dat are special new vrgeom objects (created by AC3D).

The other objects are existing cubes which crudely represent the crank & connecting rod.

engine.mof was generated by the formulae below in an Excel spreadsheet.

Basic formulae:

angle of crank = omega*time  ! first equation for engine!

crank length=r

therefore end of crank is at

x= r.cos(angle of crank),
y= r.sin(angle of crank)

end of connecting rod is at X=0 and distance L from the end of crank.

Simple geometry says that

y(piston) = y + L cos (theta)

and

theta = asin(x, L). 

The angle of the conn rod relative to the crank is easily derived from (180-theta-angle of crank) or otherwise.

The piston has an angle relative to the conn rod to keep its axis pointing along the Y axis.

Piston angle = -theta 

and this is also equal to the difference of  conn rod angle & crank angle.