private void hazardCheckLine(int p,Point2D.Double p1,Point2D.Double p2) {   
        int h = 0;
        Point2D.Double pointIntersect;
        
        Line2D.Double lineR = new Line2D.Double();
        lineR.setLine(p1, p2);
        while (h < main.map.hazards) {
            h++;
            MapHazard hz = main.map.getHazard(h);
            if (hz != null) {
                if (hz.shape == MapHazard.SHAPE_RECTANGLE) {
                    Point2D.Double hp1 = new Point2D.Double();
                    Point2D.Double hp2 = new Point2D.Double();
                    hp1.x = hz.point[1].x;
                    hp1.y = hz.point[1].y;
                    hp2.x = hz.point[2].x;
                    hp2.y = hz.point[2].y;
//                    if (hp1.x > hp2.x) {
//                        double tmp = hp2.x;
//                        hp2.x = hp1.x;
//                        hp1.x = tmp;
//                    }
//                    if (hp1.y > hp2.y) {
//                        double tmp = hp2.y;
//                        hp2.y = hp1.y;
//                        hp1.y = tmp;
//                    }
                    
                    Line2D.Double lineH = new Line2D.Double();
                    lineH.x1 = hp1.x;
                    lineH.y1 = hp1.y;
                    lineH.x2 = hp1.x;
                    lineH.y2 = hp2.y;
                    pointIntersect = getIntersectionPoint(lineR,lineH);
                    if (pointIntersect != null) {
                        hazardAddIntersect(p,h,pointIntersect);
                    }
                    
                    lineH.x1 = hp1.x;
                    lineH.y1 = hp2.y;
                    lineH.x2 = hp2.x;
                    lineH.y2 = hp2.y;
                    pointIntersect = getIntersectionPoint(lineR,lineH);
                    if (pointIntersect != null) {
                        hazardAddIntersect(p,h,pointIntersect);
                    }
                                        
                    lineH.x1 = hp2.x;
                    lineH.y1 = hp2.y;
                    lineH.x2 = hp2.x;
                    lineH.y2 = hp1.y;
                    pointIntersect = getIntersectionPoint(lineR,lineH);
                    if (pointIntersect != null) {
                        hazardAddIntersect(p,h,pointIntersect);
                    }
                                        
                    lineH.x1 = hp2.x;
                    lineH.y1 = hp1.y;
                    lineH.x2 = hp1.x;
                    lineH.y2 = hp1.y;
                    pointIntersect = getIntersectionPoint(lineR,lineH);
                    if (pointIntersect != null) {
                        hazardAddIntersect(p,h,pointIntersect);
                    }
                    
                }
                if (hz.shape == MapHazard.SHAPE_CIRCLE) {
                    Circle circle = new Circle();
                    circle.x = hz.point[1].x;
                    circle.y = hz.point[1].y;
                    circle.radius = hz.radius;
                    getCircleLineIntersect(p,h,lineR,circle);
                }
            }
        }
        
    }