private Matrix4d reorientHelix(int index) {
   Matrix4d matrix = new Matrix4d();
   matrix.setIdentity();
   matrix.setRotation(new AxisAngle4d(1, 0, 0, Math.PI / 2 * (index + 1)));
   matrix.mul(transformationMatrix);
   return matrix;
 }
示例#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);
  }