Android Vector Create getVector(float[] eventVals)

Here you can find the source of getVector(float[] eventVals)

Description

get Vector

License

Apache License

Declaration

public static double[] getVector(float[] eventVals) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

import android.hardware.SensorEvent;

public class Main {
    public static double[] getVector(SensorEvent event) {
        return getVector(event.values);
    }//from w w w  .ja  v  a  2s.  c  o m

    public static double[] getVector(float[] eventVals) {

        final double[] values = new double[3];

        int axis = 0;

        for (double value : eventVals) {
            // scale to three decimal precision
            value = BigDecimal.valueOf(value).setScale(3, 0).doubleValue();
            values[axis] = value;
            axis++;
        }

        return values;
    }
}

Related

  1. getVector(SensorEvent event)