3d Cylinder Mesh Algorithm from point3d to point3d

Feb 13, 2010 at 9:40 PM

I am modeling 3d molecules for which the atoms are spheres and the cylinders are bonds.  This works great in WPF, but the cylinders in Kit3D are proving to be quite difficult.
 
  I am stuck on creating a cylinder from Point3D_1 to Point3D_2 in Kit3D using Charles Petzold's book/dll. 
 
  I have tried multiple methods without success:
  1. Tried to convert the Petzold WPF cylinder mesh algorithm to Kit3D but would not display. I suspect the problem lies with the code that relates to vectRearRadius - but after failed tinkering, I tried option 2.
 
  2. Created a unit cylinder with stacks and slices ascending vertically from the origin , oriented along the Y axis. Then transformed with scale, translate and rotation (to move it to PointA to PointB)  - which worked fine in XY rotation, but adding an XZ rotation failed. I then tried to do this as a matrix transform (using the toX, toY, toZ code in the Petzold book).  Here I could not figure out how to determine the TrialZ (Page 321 in the book) programmatically for any cylinder orientation.   No luck.
 
  3. Finally I tried to step from Point1 to Point2 using a vector, the magnitude of 1/stacks.  At each point I would draw a circle of points centered where the vector landed and perpendicular to the vector.  Seemed like a good idea - except I could not figure out how to make the circle be perpendicular to the vector (unless the line were parallel to the Z axis).
 
  Any advice on this would be greatly appreciated.
 
  -Scott Moses

Apr 27, 2010 at 7:56 AM
Edited Apr 28, 2010 at 12:44 AM