has Cross Area - Java java.lang

Java examples for java.lang:Math Geometry Shape

Description

has Cross Area

Demo Code


//package com.java2s;

public class Main {
    public static boolean hasCrossArea(float left1, float top1,
            float right1, float bottom1, float left2, float top2,
            float right2, float bottom2) {
        return (isShadowCrossed(left1, right1, left2, right2) && isShadowCrossed(
                top1, bottom1, top2, bottom2));
    }//from   w w  w  .j a v a  2s . co m

    private static boolean isShadowCrossed(float a1, float b1, float a2,
            float b2) {
        return (isPointInnerLine(a1, a2, b2)
                || isPointInnerLine(b1, a2, b2)
                || isPointInnerLine(a2, a1, b1) || isPointInnerLine(b2, a1,
                    b1));
    }

    private static boolean isPointInnerLine(float c, float a, float b) {
        return (c >= a && c <= b);
    }
}

Related Tutorials