Android Vector Create getVector(SensorEvent event)

Here you can find the source of getVector(SensorEvent event)

Description

get Vector

License

Apache License

Declaration

public static double[] getVector(SensorEvent event) 

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.j  ava  2s. c  om

    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(float[] eventVals)