/** * Returns the current mouse position in the coordinates of the image * and is determined by the scaling factors and the position of the * image within the viewport. If the mouse is no longer in the viewport, * the last known mouse position will be returned. * * @return The position in image coordinates. */ public Point2d getCurrentMouseImagePosition() { return new Point2dImpl(this.pixelX, this.pixelY); }
private static Point2dImpl[] getPowerPoints() { return new Point2dImpl[] { new Point2dImpl(1 / 3f, 1 / 3f), new Point2dImpl(2 / 3f, 1 / 3f), new Point2dImpl(1 / 3f, 2 / 3f), new Point2dImpl(2 / 3f, 2 / 3f) }; } }
/** * Returns the current mouse position in the coordinates of the image * and is determined by the scaling factors and the position of the * image within the viewport. If the mouse is no longer in the viewport, * the last known mouse position will be returned. * * @return The position in image coordinates. */ public Point2d getCurrentMouseImagePosition() { return new Point2dImpl(this.pixelX, this.pixelY); }
private static Point2dImpl[] getPowerPoints() { return new Point2dImpl[] { new Point2dImpl(1 / 3f, 1 / 3f), new Point2dImpl(2 / 3f, 1 / 3f), new Point2dImpl(1 / 3f, 2 / 3f), new Point2dImpl(2 / 3f, 2 / 3f) }; } }
/** * @param calculateCentroid * @return a point from a double array */ public static Point2d fromDoubleArray(double[] calculateCentroid) { return new Point2dImpl((float) calculateCentroid[0], (float) calculateCentroid[1]); }
@Override public Polygon asPolygon() { final Polygon polygon = new Polygon(); polygon.points.add(new Point2dImpl(x, y)); polygon.points.add(new Point2dImpl(x + width, y)); polygon.points.add(new Point2dImpl(x + width, y + height)); polygon.points.add(new Point2dImpl(x, y + height)); return polygon; }
private void createScreenArray() { this.screenArray = new ArrayList<Point2d>(); int yInc = (int) (this.visibleArea.height/gridHeight); int xInc = (int) (this.visibleArea.width/gridWidth); for(int row = 0; row < gridHeight+1; row++){ for(int col = 0; col < gridWidth + 1; col++){ this.screenArray.add(new Point2dImpl(col * xInc, row * yInc)); } } }
/** * Create a random point in ([0..1], [0..1]). * * @return random point. */ public static Point2d createRandomPoint() { return new Point2dImpl((float) Math.random(), (float) Math.random()); }
public DragonCurve() { this.startOfDragon = new Point2dImpl(1/3f,0.5f); endOfDragon = new Point2dImpl(2/3f,0.5f); this.currentCurve = new PointList(startOfDragon,endOfDragon); }
private FacialKeypoint createInterpolated(FacialKeypointType type, FacialKeypoint left, FacialKeypoint right) { if (left == null || right == null) return null; final float x = right.position.x - left.position.x; final float y = right.position.y - left.position.y; return new FacialKeypoint(type, new Point2dImpl(x, y)); }
@Override public void mouseClicked(MouseEvent event) { drawPoint = new Point2dImpl(event.getX(), event.getY()); if (this.drawPoint != null) { setEBowl(); } }
@Override public void mousePressed(MouseEvent e) { if (e.isAltDown()) { pressClick = new Point2dImpl(e.getX(), e.getY()); } }
@Override public void processSegment(final QuadCurve2D segment, final double startT, final double endT) { if (0.0 == startT) points.add(new Point2dImpl( (float) segment.getX1(), (float) segment.getY1())); points.add(new Point2dImpl( (float) segment.getX2(), (float) segment.getY2())); } });
@Override public void processSegment(final QuadCurve2D segment, final double startT, final double endT) { if (0.0 == startT) points.add(new Point2dImpl( (float) segment.getX1(), (float) segment.getY1())); points.add(new Point2dImpl( (float) segment.getX2(), (float) segment.getY2())); } });
/** * @param pt * @return */ static Point2dImpl projectOrtho(Matrix pt) { final Point2dImpl po = new Point2dImpl(); po.x = (float) pt.get(0, 0); po.y = (float) pt.get(1, 0); return po; }
@Override public void draw( final MBFImage vis, final int xoffset, final int yoffset, final PointList pl ) { for( final Point2d p : pl ) { final Point2d pp = new Point2dImpl( p ); p.translate( xoffset, yoffset ); vis.drawPoint( pp, RGBColour.RED, 2 ); } } };
/** * @param pt * @return */ static Point2dImpl projectOrtho(Matrix pt) { final Point2dImpl po = new Point2dImpl(); po.x = (float) pt.get(0, 0); po.y = (float) pt.get(1, 0); return po; }
@Override public void processSegment(final QuadCurve2D segment, final double startT, final double endT) { if (0.0 == startT) p.addVertex(new Point2dImpl( (float) segment.getX1(), (float) segment.getY1())); p.addVertex(new Point2dImpl( (float) segment.getX2(), (float) segment.getY2())); } }
@Override public void drawToImage(MBFImage image) { image.fill(RGBColour.WHITE); final int nPoints = touchArray.size(); final float gridX = nPoints % (GRIDX + 1); final float gridY = nPoints / (GRIDX + 1); final Point2dImpl currentpoint = new Point2dImpl( (image.getWidth() * (gridX / GRIDX)), ((image.getHeight()) * (gridY / GRIDY)) ); drawTarget(image, currentpoint); }
private Point2dImpl normContactDelta(final Circle paddle, final Circle ball) { final float px = paddle.getX(); final float py = paddle.getY(); final float dx = ball.getX() - px; final float dy = ball.getY() - py; final float plusX = dx * (paddle.getRadius() / (ball.getRadius() + paddle.getRadius())); final float plusY = dy * (paddle.getRadius() / (ball.getRadius() + paddle.getRadius())); final float prop = (float) (1f / Math.sqrt(plusX * plusX + plusY * plusY)); return new Point2dImpl(plusX * prop, plusY * prop); }