Changeset 3939 in josm


Ignore:
Timestamp:
2011-03-02T12:12:03+01:00 (13 years ago)
Author:
stoecker
Message:

hopefully fix #5427

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r3919 r3939  
    303303                    //find if the new points overlap existing segments (in case of 90 degree angles)
    304304                    Node prevNode = getPreviousNode(selectedSegment.lowerIndex);
    305                     boolean nodeOverlapsSegment = prevNode != null && Geometry.segmentsParralel(initialN1en, prevNode.getEastNorth(), initialN1en, newN1en);
     305                    boolean nodeOverlapsSegment = prevNode != null && Geometry.segmentsParallel(initialN1en, prevNode.getEastNorth(), initialN1en, newN1en);
    306306                    boolean hasOtherWays = this.hasNodeOtherWays(selectedSegment.getFirstNode(), selectedSegment.way);
    307307
     
    320320                    //find if the new points overlap existing segments (in case of 90 degree angles)
    321321                    Node nextNode = getNextNode(selectedSegment.lowerIndex + 1);
    322                     nodeOverlapsSegment = nextNode != null && Geometry.segmentsParralel(initialN2en, nextNode.getEastNorth(), initialN2en, newN2en);
     322                    nodeOverlapsSegment = nextNode != null && Geometry.segmentsParallel(initialN2en, nextNode.getEastNorth(), initialN2en, newN2en);
    323323                    hasOtherWays = hasNodeOtherWays(selectedSegment.getSecondNode(), selectedSegment.way);
    324324
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r3650 r3939  
    290290    }
    291291
    292     public static boolean segmentsParralel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
     292    public static boolean segmentsParallel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
    293293        // Convert line from (point, point) form to ax+by=c
    294294        double a1 = p2.getY() - p1.getY();
     
    300300        // Solve the equations
    301301        double det = a1 * b2 - a2 * b1;
    302         return Math.abs(det) < 1e-13;
     302        // remove influence of of scaling factor
     303        det /= Math.sqrt(a1*a1 + b1*b1) * Math.sqrt(a2*a2 + b2*b2);
     304        return Math.abs(det) < 1e-3;
    303305    }
    304306
Note: See TracChangeset for help on using the changeset viewer.