NanoComp / libctl

Guile-based library implementing flexible control files for scientific simulations
GNU General Public License v2.0
19 stars 23 forks source link

elliptic cylinder #33

Open stevengj opened 6 years ago

stevengj commented 6 years ago

From https://github.com/stevengj/meep/issues/606: A recent post from the mailing list involved a request for an elliptic cylinder to be added as a new geometry object. This would have to be added first to libctl. An elliptic cylinder would be a useful compliment to the existing Cylinder and Ellipsoid objects.

cc @HomerReid

stevengj commented 6 years ago

Basically, this will be a subtype of cylinder that has additional properties: r2 (other semiaxis) and e1 and e2 (the two ellipse axes).

Similar to a block object, the three vectors (r1e1,r2e2,axis) define a 3x3 matrix M. You can cache inv(M) in the object (just like for a block). To check whether a point is in the elliptical cylinder, you first multiply inv(M) * (point - center) to convert the displacement to the "cylinder coordinates". In this coordinate system everything becomes easy: it is just an ordinary circular cylinder oriented along the 3rd axis. (To compute the normal vector, you will have to rotate the resulting vector back to the original coordinate system.)