Java Float Number Clip clipToRange(float[][] in, float min, float max)

Here you can find the source of clipToRange(float[][] in, float min, float max)

Description

clip To Range

License

Open Source License

Declaration

public static void clipToRange(float[][] in, float min, float max) 

Method Source Code

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

public class Main {
    public static void clipToRange(float[][] in, float min, float max) {
        int width = in[0].length;
        int height = in.length;
        for (int yy = 0; yy < height; yy++) {
            for (int xx = 0; xx < width; xx++) {
                if (in[yy][xx] > max) {
                    in[yy][xx] = max;//  w  ww .  j a  v  a  2  s .co  m
                }
                if (in[yy][xx] < min) {
                    in[yy][xx] = min;
                }
            }
        }
    }

    public static void clipToRange(float[] in, float min, float max) {
        int height = in.length;
        for (int yy = 0; yy < height; yy++) {
            if (in[yy] > max) {
                in[yy] = max;
            }
            if (in[yy] < min) {
                in[yy] = min;
            }
        }
    }

    public static void clipToRange(double[] in, float min, float max) {
        int height = in.length;
        for (int yy = 0; yy < height; yy++) {
            if (in[yy] > max) {
                in[yy] = max;
            }
            if (in[yy] < min) {
                in[yy] = min;
            }
        }
    }
}

Related

  1. clip(float value, float bottom, float top)
  2. clip(float x)
  3. clipf(float num, float mini, float maxi)
  4. clipFloat(float value, float min, float max)
  5. clipNormalized(final float a)