Java Cube cubeToBounds(float[] target, float x, float y, float z, float w, float d, float h)

Here you can find the source of cubeToBounds(float[] target, float x, float y, float z, float w, float d, float h)

Description

Converts a cuboid like bounding box to an actual bounding box.

License

Open Source License

Parameter

Parameter Description
target - target bounding box
x - x coord
y - y coord
z - z coord
w - width
d - depth
h - height

Return

target

Declaration

public static float[] cubeToBounds(float[] target, float x, float y,
        float z, float w, float d, float h) 

Method Source Code

//package com.java2s;
/*/*ww w. j  a  v a2s.c om*/
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 IceDragon200
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

public class Main {
    /**
     * Converts a cuboid like bounding box to an actual bounding box.
     *
     * @param target - target bounding box
     * @param x - x coord
     * @param y - y coord
     * @param z - z coord
     * @param w - width
     * @param d - depth
     * @param h - height
     * @return target
     */
    public static float[] cubeToBounds(float[] target, float x, float y,
            float z, float w, float d, float h) {
        assert target.length == 6;
        target[0] = x;
        target[1] = y;
        target[2] = z;
        target[3] = x + w;
        target[4] = y + d;
        target[5] = z + h;
        return target;
    }

    /**
     * Converts a cuboid like bounding box to an actual bounding box.
     *
     * @param target - target bounding box
     * @param src - source bounding box
     * @return target
     */
    public static float[] cubeToBounds(float[] target, float[] src) {
        assert src.length == 6;
        return cubeToBounds(target, src[0], src[1], src[2], src[3], src[4],
                src[5]);
    }
}

Related

  1. cube2rect(byte[][][] cube)
  2. cubed(final int input)
  3. cubeIntersectsSphere(int x1, int y1, int z1, int x2, int y2, int z2, int sX, int sY, int sZ, int radius)
  4. cubeTextureArray(float x0, float y0, float x1, float y1)
  5. cubeTextureFace(float x0, float y0, float x1, float y1)
  6. cubeVertexArray(float x, float y, float z, float size)