Esempio n. 1
0
  /* (non-Javadoc)
   * @see org.biojava.nbio.structure.quaternary.core.AxisAligner#getGeometicCenterTransformation()
   */
  @Override
  public Matrix4d getGeometicCenterTransformation() {
    run();

    Matrix4d geometricCentered = new Matrix4d(reverseTransformationMatrix);
    geometricCentered.setTranslation(new Vector3d(getGeometricCenter()));

    return geometricCentered;
  }
Esempio n. 2
0
  public static void main(String[] args) {
    double[] vertexCoords = {
      1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0
    };

    int[][] faceIndices = {{0, 3, 2, 1}, {4, 0, 1}, {4, 1, 2}, {4, 2, 3}, {4, 3, 0}};

    ConvexPolyhedron poly = new ConvexPolyhedron(vertexCoords, faceIndices);

    PolyTree pyramid = new PolyTree("pyramid", poly);
    PolyTree hourglass = new PolyTree("hourglass");

    Matrix4d X = new Matrix4d();
    X.setIdentity();
    X.setTranslation(new Vector3d(0, 0, -1));
    hourglass.addComponent("bottom", pyramid, X);

    X.setTranslation(new Vector3d(0, 0, 1));
    X.setRotation(new AxisAngle4d(1, 0, 0, Math.PI));
    hourglass.addComponent("top", pyramid, X);

    hourglass.buildBoundingHull(PolyTree.OBB_HULL);
  }
Esempio n. 3
0
  private void calcTransformationBySymmetryAxes() {
    Vector3d[] axisVectors = new Vector3d[2];
    axisVectors[0] = new Vector3d(principalRotationVector);
    axisVectors[1] = new Vector3d(referenceVector);

    //  y,z axis centered at the centroid of the subunits
    Vector3d[] referenceVectors = new Vector3d[2];
    referenceVectors[0] = new Vector3d(Z_AXIS);
    referenceVectors[1] = new Vector3d(Y_AXIS);

    transformationMatrix = alignAxes(axisVectors, referenceVectors);

    // combine with translation
    Matrix4d combined = new Matrix4d();
    combined.setIdentity();
    Vector3d trans = new Vector3d(subunits.getCentroid());
    trans.negate();
    combined.setTranslation(trans);
    transformationMatrix.mul(combined);

    // for helical geometry, set a canonical view for the Z direction
    calcZDirection();
  }
  private static Matrix4d combineTransformation(
      Matrix4d matrix, Vector3d translation, Vector3d rotation) {
    Matrix4d gM = new Matrix4d(matrix);
    Matrix4d m = new Matrix4d();

    m.setIdentity();
    m.setTranslation(translation);
    gM.mul(m);

    m.setIdentity();
    m.rotZ(rotation.z);
    gM.mul(m);

    m.setIdentity();
    m.rotY(rotation.y);
    gM.mul(m);

    m.setIdentity();
    m.rotX(rotation.x);
    gM.mul(m);

    return gM;
  }