Java Line Intersect intersects(int start1, int length1, int start2, int length2)

Here you can find the source of intersects(int start1, int length1, int start2, int length2)

Description

intersects

License

Open Source License

Declaration

public static boolean intersects(int start1, int length1, int start2, int length2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014,2015 Hideki Yatomi
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

public class Main {
    public static boolean intersects(int start1, int length1, int start2, int length2) {
        if (length1 == 0)
            length1 = 1;/*from   ww  w .j a  v  a  2 s  . c o m*/
        if (length2 == 0)
            length2 = 1;
        int min1 = Math.min(start1, start1 + length1);
        int max1 = Math.max(start1, start1 + length1);
        int min2 = Math.min(start2, start2 + length2);
        int max2 = Math.max(start2, start2 + length2);

        return (min1 < max2) && (min2 < max1);
    }
}

Related

  1. intersectionZJU(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  2. intersectLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double[] point)
  3. intersectLineSegments(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  4. intersectLinesWithParams(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double[] params)
  5. intersects(int b1, int e1, int b2, int e2)
  6. intersects(int x0, int y0, int w0, int h0, int x, int y, int w, int h)