Package org.mt4j.util.math

Examples of org.mt4j.util.math.Matrix


        MTComponent res = this.getGlobalMatrixRecursive(current.getParent(), currentMatrix);
        if (!res.getLocalMatrix().isIdentity()){
          currentMatrix.multLocal(res.getLocalMatrix());
          //We can set
//          System.out.println(" Recursive loop - setting " + res.getName() + " global matrix");
          res.globalMatrix = new Matrix(currentMatrix);
          res.setGlobalMatrixDirty(false);
        }
        //System.out.println("Applying Matrix of: '" + res.getName() + "' Matrix: " + res.getLocalBasisMatrix().toString());
      }else{
        //Currents global matrix isnt dirty -> apply the global matrix and stop recursion upwards
//        System.out.println(" Recursive loop - " + current.getParent().getName() + "'s global matrix is NOT dirty - stop recursion");
        Matrix parentLocalToGlobal = current.getParent().getGlobalMatrix();
        currentMatrix.multLocal(parentLocalToGlobal);
      }
    }else{
//      System.out.println(" Recursive loop - " + current.getName() + " has no parent - stop recursion and use its local as its global matrix");
      if (current.isGlobalMatrixDirty()){
        current.globalMatrix = new Matrix(current.getLocalMatrix());
        current.setGlobalMatrixDirty(false);
      }
    }
    return current;
  }
View Full Code Here


   *
   * @return the absolute global to local matrix
   * , the absolute inverse transformation matrix of the object
   */
  public Matrix getGlobalInverseMatrix() {
    Matrix resMatrix = this.globalToLocalMatrix;
    //Calculate the absolute local to global matrix only if necessary
    if (this.isGlobalInverseMatrixDirty()){
//      System.out.println("Getting global inverse of: " + this.getName() + " -its dirty!");
      if (this.getParent()!= null){
        resMatrix = new Matrix(this.getLocalInverseMatrix());
        this.getGlobalInvMatrixRecursive(this.getParent(), resMatrix);
        this.globalToLocalMatrix = resMatrix;
      }else{
        //no parent -> Global inverse is local inverse
        this.globalToLocalMatrix = this.getLocalInverseMatrix();
View Full Code Here

   */
  public static Matrix getTransformToDestinationParentSpace(MTComponent originComponent, MTComponent destinationComponent){
//    /*
    if (originComponent.getParent() != null){
      //Transform to world space, keeping only the objects internal transform
      Matrix compParentWorld = new Matrix(originComponent.getParent().getGlobalMatrix());
      //Transform to destination space, so that the destination
      //will not change the actual objects transform, shape and position
      //by negating the destination obj's absolute transform
      destinationComponent.getGlobalInverseMatrix().mult(compParentWorld, compParentWorld);
      return compParentWorld;
View Full Code Here

   */
  public static Matrix getTransformToDestinationLocalSpace(MTComponent originComponent, MTComponent destinationComponent){
//    /*  //Worked with centerpoint
      //Transform to global space, keeping only the objects internal transform
//      componentToTransfrom.transform(componentToTransform.getParent().getAbsoluteLocalToWorldMatrix());
      Matrix compParentWorld = new Matrix(originComponent.getGlobalMatrix());
     
      //Transform to destination space, so that the destination
      //will not change the actual objects transform, shape and position
      //by negating the destination obj's absolute transform
//      componentToTransform.transform(destinationComponent.getAbsoluteWorldToLocalMatrix());
View Full Code Here

    }else{
      try {
        if (this.inversePrecisionErrors >= invPrecisionThreshold){
          this.inversePrecisionErrors = 0;
//          System.out.println("Matrix inverted at: " + this);
          this.setLocalInverseMatrixInternal(new Matrix(this.getLocalMatrix()).invertLocal());
        }else{
          this.setLocalInverseMatrixInternal(this.getLocalInverseMatrix().multLocal(ms[1]));
        }
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

    }else{
      try {
        if (this.inversePrecisionErrors >= invPrecisionThreshold){
          this.inversePrecisionErrors = 0;
//          System.out.println("Matrix inverted at: " + this);
          this.setLocalInverseMatrixInternal(new Matrix(this.getLocalMatrix()).invertLocal());
        }else{
          this.setLocalInverseMatrixInternal(this.getLocalInverseMatrix().multLocal(ms[1]));
        }
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

    }else{
      try {
        if (this.inversePrecisionErrors >= invPrecisionThreshold){
          this.inversePrecisionErrors = 0;
//          System.out.println("Matrix inverted at: " + this);
          this.setLocalInverseMatrixInternal(new Matrix(this.getLocalMatrix()).invertLocal());
        }else{
          this.setLocalInverseMatrixInternal(this.getLocalInverseMatrix().fastMult43(ms[1],this.getLocalInverseMatrix()));
        }
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

//    System.out.println("Det b4: " + getLocalMatrix().determinant());
//    Vector3D v1 = new Vector3D(2,3,4);
//    Vector3D v2 = new Vector3D(v1);
//    v1.transform(this.getLocalMatrix());
   
    Matrix m = new Matrix(this.getLocalMatrix());
//        m.orthonormalizeLocal();
    //can we use 3x3 otrhogonalization on a 4x4 matrix just using the middle part?
    //-seems yes
    m.orthonormalizeUpperLeft();
        //Re-Apply scale because its removed at orthonormalization
//        m.mult(Matrix.getScalingMatrix(Vector3D.ZERO_VECTOR, scale.x, scale.y, scale.z), m);
        m.scale(scale);
        //Automatically inverts() the localMatrix, so exact inverse again! :)
        this.setLocalMatrix(m);
       
//        v2.transform(this.getLocalMatrix());
//        System.out.println("Diff: " + v2.getSubtracted(v1));
View Full Code Here

  @Override
  public float getCurrentUnscaledWidth(){
//    Vector3D v = this.getReferenceComp().getWidthXYVectObjSpace();
    Vector3D v = getWidthVectorLocal();
   
    Matrix refCompLocalToWorld = new Matrix(this.getReferenceComp().getGlobalMatrix());
    //Remove translation for direction vectors(width/height)
    refCompLocalToWorld.removeTranslationFromMatrix();
   
    //obj width vect to world space
    v.transform(refCompLocalToWorld);
   
   
   
    Matrix svgButtonAbsInv = new Matrix(this.getCompToResize().getGlobalInverseMatrix());
    //TODO doch wieder localbase von svg dazutransformen?
    //svgbutton inverse parent relative machen
    svgButtonAbsInv.multLocal(this.getCompToResize().getLocalMatrix());
    //Remove translation for direction vectors(width/height)
    svgButtonAbsInv.removeTranslationFromMatrix();
    //Width vect in svgbutton parent relative space
    v.transform(svgButtonAbsInv);
    float width = v.length();
    return width;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.jMT.input.gestureAction.DefaultButtonClickAction#resize(float, float)
   */
  @Override
  public void resize(float newWidth, float newHeight){
    Matrix refCompLocalToWorld = new Matrix(this.getReferenceComp().getGlobalMatrix());
   
    //Center into world space
    Vector3D refCompCenter = this.centerObjSpace.getCopy();
    refCompCenter.transform(refCompLocalToWorld);
   
    //Remove translation for direction vectors(width/height)
    refCompLocalToWorld.removeTranslationFromMatrix();
   
    //Width vect into world space
    Vector3D objSpaceWidth = this.widthObjSpace.getCopy();
    objSpaceWidth.transform(refCompLocalToWorld);
//    System.out.println(" world Width vect of reference component: " + objSpaceWidth);
   
    /////Transform width/height/center to svgbutton relative
    Matrix svgButtonAbsInv = new Matrix(this.getCompToResize().getGlobalInverseMatrix());
   
    //Center in svgbutton relative
    refCompCenter.transform(svgButtonAbsInv);
//    System.out.println("Centerpoint svgRelative: " + refCompCenter);
   
    //TODO doch wieder localbase von svg dazutransformen?
    //svgbutton inverse parent relative machen
    svgButtonAbsInv.multLocal(this.getCompToResize().getLocalMatrix());
   
//    //Center in svgbutton relative
//    refCompCenter.transform(svgButtonAbsInv);
//    System.out.println("Centerpoint svgRelative: " + refCompCenter);
   
    //Remove translation for direction vectors(width/height)
    svgButtonAbsInv.removeTranslationFromMatrix();
   
    //Width vect in svgbutton parent relative
    objSpaceWidth.transform(svgButtonAbsInv);
//    System.out.println(" svgbutton space Width vect of reference component: " + objSpaceWidth);
   
View Full Code Here

TOP

Related Classes of org.mt4j.util.math.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.