Here you can find the source of quantisePoint(Point2D.Double dpos, Point gpos)
Parameter | Description |
---|---|
dpos | input definite floating point graphics position |
gpos | output graphics position object |
public static void quantisePoint(Point2D.Double dpos, Point gpos)
//package com.java2s; //License from project: LGPL import java.awt.Point; import java.awt.geom.Point2D; public class Main { /**// w w w. ja va 2s. co m * Maps a floating point graphics position to an integer graphics * position, that is a 2-dimensional grid cell index. * It does this by calling {@link #ifloor} on both coordinates. * The input coordinates must not be NaN. * * @param dpos input definite floating point graphics position * @param gpos output graphics position object */ public static void quantisePoint(Point2D.Double dpos, Point gpos) { gpos.x = ifloor(dpos.x); gpos.y = ifloor(dpos.y); } /** * Determines the integer not larger than a given non-NaN * floating point value. * * @param x definite floating point value * @return floor of input * @see java.lang.Math#floor */ public static int ifloor(double x) { int y = (int) x; return x >= 0 || x == y || y == Integer.MIN_VALUE ? y : y - 1; } }