Java Vector to vectorToColor(float x, float y, float z)

Here you can find the source of vectorToColor(float x, float y, float z)

Description

This method transforms given vector's coordinates into ARGB color (A is always = 255).

License

Open Source License

Parameter

Parameter Description
x X factor of the vector
y Y factor of the vector
z Z factor of the vector

Return

color representation of the given vector

Declaration

private static int vectorToColor(float x, float y, float z) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  ww  w  .  java2s  .  c  om
     * This method transforms given vector's coordinates into ARGB color (A is
     * always = 255).
     * 
     * @param x
     *            X factor of the vector
     * @param y
     *            Y factor of the vector
     * @param z
     *            Z factor of the vector
     * @return color representation of the given vector
     */
    private static int vectorToColor(float x, float y, float z) {
        int r = Math.round(255 * (x + 1f) / 2f);
        int g = Math.round(255 * (y + 1f) / 2f);
        int b = Math.round(255 * (z + 1f) / 2f);
        return (255 << 24) + (r << 16) + (g << 8) + b;
    }
}

Related

  1. toHashSetD(Vector vec)
  2. toIntArray(Vector vec)
  3. toIntArray(Vector vect)
  4. toPercent(Vector members, HashMap mapMemberToValue)
  5. vector2doubles(Vector _v)
  6. vectorTolatLonDegrees(double X, double Y, double Z)
  7. vectorToMatrixArray(int M, int N, float[] a, float[][] b)