import javax.vecmath.*; import javax.media.j3d.*; // Canvas3D etc class Helix implements Curve3f { float r; float a; double upAngle; Helix ( float radius, float aIn ) { r = radius; a = aIn; upAngle = - Math.asin ( a / Math.sqrt ( 4* Math.PI*Math.PI + a*a) ); } public Point3f valueAt ( float t ) { return new Point3f ( r * (float) Math.cos ( 2 * t * Math.PI ), r * (float) Math.sin ( 2 * t * Math.PI ), a * t ); } public Vector3f Vector3fAt ( float t ) { return new Vector3f ( r * (float) Math.cos ( 2 * t * Math.PI ), r * (float) Math.sin ( 2 * t * Math.PI ), a * t ); } public Transform3D frameAt ( float t ) { Transform3D spin = new Transform3D(); Transform3D temp1 = new Transform3D(); Transform3D temp2 = new Transform3D(); spin.setTranslation ( Vector3fAt ( t ) ); temp1.rotZ ( 2*Math.PI*t + Math.PI/2 ); spin.mul ( temp1 ); temp2.rotY ( upAngle ); //System.out.println ( upAngle ); spin.mul ( temp2 ); // they work backwards (bottom to top) return spin; } }