Java Matrix Convert To matrixToQuaternion(float[] m)

Here you can find the source of matrixToQuaternion(float[] m)

Description

matrix To Quaternion

License

Open Source License

Declaration

public static double[] matrixToQuaternion(float[] m) 

Method Source Code

//package com.java2s;

public class Main {
    public static double[] matrixToQuaternion(float[] m) {

        double[] res = new double[4];

        // w/*from   w ww .  j  a va  2s.c  o  m*/
        res[0] = Math.sqrt(1.0 + m[0] + m[5] + m[10]) / 2.0;

        double w4 = (4.0 * res[0]);
        res[1] = (m[9] - m[6]) / w4; // x
        res[2] = (m[2] - m[8]) / w4; // y
        res[3] = (m[4] - m[1]) / w4; // z

        return res;
    }
}

Related

  1. matrixCastToDouble(String[][] m)
  2. matrixToArray(double[][] m)
  3. matrixToArray(int[][] input, int fromRow, int rows, int fromColumn, int columns)
  4. matrixToShort(final byte[][] b)
  5. toDiagonalMatrix(double[] x)