Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;

public class Main {
    final private static String TAG = "MatrixHelper";

    public static float[] maxMinXYZ(float[] array) {
        float maxX = 0.0f, minX = 0.0f, maxY = 0.0f, minY = 0.0f, maxZ = 0.0f, minZ = 0.0f;
        float[] res = new float[6];

        for (int i = 0; i < array.length; i = i + 3) {

            // Max
            if (array[i] > maxX) {
                maxX = array[i];
            }
            if (array[i + 1] > maxY) {
                maxY = array[i + 1];
            }
            if (array[i + 2] > maxZ) {
                maxZ = array[i + 2];
            }

            // Min
            if (array[i] < minX) {
                minX = array[i];
            }
            if (array[i + 1] < minY) {
                minY = array[i + 1];
            }
            if (array[i + 2] < minZ) {
                minZ = array[i + 2];
            }
        }
        res[0] = maxX;
        res[1] = minX;

        res[2] = maxY;
        res[3] = minY;

        res[4] = maxZ;
        res[5] = minZ;

        Log.d(TAG, "maxX = " + res[0]);
        Log.d(TAG, "minX = " + res[1]);

        Log.d(TAG, "maxY = " + res[2]);
        Log.d(TAG, "minY = " + res[3]);

        Log.d(TAG, "maxZ = " + res[4]);
        Log.d(TAG, "minZ = " + res[5]);
        return res;
    }
}