/**
   * Return a midpoint of a helix, calculated from three positions of three adjacent subunit
   * centers.
   *
   * @param p1 center of first subunit
   * @param p2 center of second subunit
   * @param p3 center of third subunit
   * @return midpoint of helix
   */
  private Point3d getMidPoint(Point3d p1, Point3d p2, Point3d p3) {
    Vector3d v1 = new Vector3d();
    v1.sub(p1, p2);
    Vector3d v2 = new Vector3d();
    v2.sub(p3, p2);
    Vector3d v3 = new Vector3d();
    v3.add(v1);
    v3.add(v2);
    v3.normalize();

    // calculat the total distance between to subunits
    double dTotal = v1.length();
    // calculate the rise along the y-axis. The helix axis is aligned with y-axis,
    // therfore, the rise between subunits is the y-distance
    double rise = p2.y - p1.y;
    // use phythagorean theoremm to calculate chord length between two subunit centers
    double chord = Math.sqrt(dTotal * dTotal - rise * rise);
    //		System.out.println("Chord d: " + dTotal + " rise: " + rise + "chord: " + chord);
    double angle = helixLayers.getByLargestContacts().getAxisAngle().angle;

    // using the axis angle and the chord length, we can calculate the radius of the helix
    // http://en.wikipedia.org/wiki/Chord_%28geometry%29
    double radius = chord / Math.sin(angle / 2) / 2; // can this go to zero?
    //		System.out.println("Radius: " + radius);

    // project the radius onto the vector that points toward the helix axis
    v3.scale(radius);
    v3.add(p2);
    //		System.out.println("Angle: " +
    // Math.toDegrees(helixLayers.getByLowestAngle().getAxisAngle().angle));
    Point3d cor = new Point3d(v3);
    return cor;
  }
 /* (non-Javadoc)
  * @see org.biojava.nbio.structure.quaternary.core.AxisAligner#getDimension()
  */
 @Override
 public Vector3d getDimension() {
   run();
   Vector3d dimension = new Vector3d();
   dimension.sub(maxBoundary, minBoundary);
   dimension.scale(0.5);
   return dimension;
 }
Beispiel #3
0
 protected void computeCircle() {
   Vector3d center = new Vector3d((Vector3d) get(0));
   Vector3d p2 = new Vector3d((Vector3d) get(1));
   p2.sub(center);
   double radius = p2.length();
   removeAllElements();
   double angle = 0;
   double incAngle = 2 * Math.PI / sides;
   for (int i = 0; i < sides; i++) {
     super.add(
         new Vector3d(
             center.x + radius * Math.cos(angle), center.y + radius * Math.sin(angle), 0));
     angle += incAngle;
   }
   super.add(new Vector3d(center.x + radius, center.y, 0));
 }