List of usage examples for android.graphics Matrix mapVectors
public void mapVectors(float[] vecs)
From source file:Main.java
private static float transformAngle(Matrix m, float angleRadians) { // Construct and transform a vector oriented at the specified clockwise // angle from vertical. Coordinate system: down is increasing Y, right is // increasing X. float[] v = new float[2]; v[0] = (float) Math.sin(angleRadians); v[1] = (float) Math.cos(angleRadians); m.mapVectors(v); // Derive the transformed vector's clockwise angle from vertical. float result = (float) Math.atan2(v[0], -v[1]); if (result < -Math.PI / 2) { result += Math.PI;//from w w w . j av a 2 s .c o m } else if (result > Math.PI / 2) { result -= Math.PI; } return result; }
From source file:Main.java
private static float transformAngle(Matrix m, float angleRadians) { // Construct and transform a vector oriented at the specified clockwise // angle from vertical. Coordinate system: down is increasing Y, right is // increasing X. float[] v = new float[2]; v[0] = (float) Math.sin(angleRadians); v[1] = (float) -Math.cos(angleRadians); m.mapVectors(v); // Derive the transformed vector's clockwise angle from vertical. float result = (float) Math.atan2(v[0], -v[1]); if (result < -Math.PI / 2) { result += Math.PI;/* w w w . ja v a2 s . c o m*/ } else if (result > Math.PI / 2) { result -= Math.PI; } return result; }