Example usage for android.graphics Matrix mapVectors

List of usage examples for android.graphics Matrix mapVectors

Introduction

In this page you can find the example usage for android.graphics Matrix mapVectors.

Prototype

public void mapVectors(float[] vecs) 

Source Link

Document

Apply this matrix to the array of 2D vectors, and write the transformed vectors back into the array.

Usage

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;
}