Java Rectangle Intersect intersects(float cx, float cy, float radius, float left, float top, float right, float bottom)

Here you can find the source of intersects(float cx, float cy, float radius, float left, float top, float right, float bottom)

Description

intersects

License

Open Source License

Declaration

public static boolean intersects(float cx, float cy, float radius,
            float left, float top, float right, float bottom) 

Method Source Code

//package com.java2s;
/*----------------------------------------------------------------------------- 
 * vlsSMLM Software// ww w  .  j  a  v a 2 s .c  o m
 * 
 * Copyright (C) 2014 Matthieu Palayret
 * Department of Chemistry
 * University of Cambridge, UK
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *---------------------------------------------------------------------------*/

public class Main {
    public static boolean intersects(float cx, float cy, float radius,
            float left, float top, float right, float bottom) {
        float closestX = (cx < left ? left : (cx > right ? right : cx));
        float closestY = (cy < top ? top : (cy > bottom ? bottom : cy));
        float dx = closestX - cx;
        float dy = closestY - cy;

        return (dx * dx + dy * dy) <= radius * radius;
    }
}

Related

  1. intersects(double oldx, double oldy, double oldwidth, double oldheight, double oldx2, double oldy2, double oldwidth2, double oldheight2)
  2. intersects(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  3. intersects(final float x, final float y, final float z, final int sx, final int sy, final int sz)
  4. intersects(final Rectangle elementRect, final Rectangle viewportRect)
  5. intersects(final Rectangle2D a, final Rectangle2D b)
  6. intersects(Point p1, Point p2, Rectangle rect)
  7. intersects(Rectangle aRectangle, Line2D aLine)
  8. intersects(Rectangle rect1, Rectangle rect2, boolean vertical)
  9. intersects(Rectangle2D r, Object o)