Java Angle angleFromR(final double[][] R)

Here you can find the source of angleFromR(final double[][] R)

Description

compute the angle of rotation from a rotation matrix.

License

Open Source License

Parameter

Parameter Description
R rotation matrix

Declaration

public static double angleFromR(final double[][] R) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w  w w  .  j  a va2s .com
     * compute the angle of rotation from a rotation matrix. The returned value
     * is in the range [0, PI].
     * 
     * @param R
     *            rotation matrix
     */
    public static double angleFromR(final double[][] R) {
        assert cols(R) >= 3;
        assert rows(R) >= 3;

        final double tr = R[0][0] + R[1][1] + R[2][2];
        final double theta = Math.acos((tr - 1.0) / 2.0);
        return theta;
    }

    public static int cols(final double[][] A) {
        return A[0].length;
    }

    public static int rows(final double[] a) {
        return a.length;
    }

    public static int rows(final double[][] A) {
        return A.length;
    }
}

Related

  1. angleAdd(int i, final int i1)
  2. angleDistance(double angle1, double angle2)
  3. angleEquals(double angle1, double angle2, double epsilon)
  4. AngleEvaluation(double angle, int effectIndex, int angleNeeded, int orbValue)
  5. angleFromDirection(float dirX, float dirY)
  6. angleInDegrees(float ownerRotation, float x1, float y1, float x2, float y2)
  7. angleInRadians(float originX, float originY, float targetX, float targetY)
  8. angleInRange(double angle, double min, double max)
  9. angleInRange(float theta1, float theta2, float tolerance)