Java Float to Int floatToInteger(float f, float f2, float offset, boolean rotate)

Here you can find the source of floatToInteger(float f, float f2, float offset, boolean rotate)

Description

float To Integer

License

Open Source License

Declaration

private static int floatToInteger(float f, float f2, float offset, boolean rotate) 

Method Source Code

//package com.java2s;

public class Main {
    private static int floatToInteger(float f, float f2, float offset, boolean rotate) {
        if (rotate) {
            int i = (int) ((f2 - f) * 2 * offset);
            if (i > offset) {
                return i - (int) (2 * offset);
            } else if (i < -offset) {
                return i + (int) (2 * offset);
            } else {
                return i;
            }// w  w  w  . j  a v a 2 s .  c  o  m
        } else {
            if (f != 0.0f) {
                return (int) ((f2 - f) * offset / f);
            } else {
                return (int) ((f2 - f) * offset);
            }
        }
    }
}

Related

  1. floatToInt(float f, int defaultValue)
  2. floatToInt(float[] ints)
  3. floatToInt(float[] values)
  4. floatToInt(String flot)
  5. floatToInteger(final float value)