public static Point2D getPathIntersect ( final WiresConnection connection , final MultiPath path , final Point2D c , final int pointIndex ) { final Point2DArray plist = connection . getConnector ( ) . getLine ( ) . getPoint2DArray ( ) ; Point2D p = plist . get ( pointIndex ) . copy ( ) ; final Point2D offsetP = path . getComputedLocation ( ) ; p . offset ( - offsetP . getX ( ) , - offsetP . getY ( ) ) ; // p may be within the path boundary, so work of a vector that guarantees a point outside final double width = path . getBoundingBox ( ) . getWidth ( ) ; if ( c . equals ( p ) ) { // this happens with the magnet is over the center of the opposite shape // so either the shapes are horizontall or vertically aligned. // this means we can just take the original centre point for the project // without this the project throw an error as you cannot unit() something of length 0,0 p . offset ( offsetP . getX ( ) , offsetP . getY ( ) ) ; } try { p = getProjection ( c , p , width ) ; final Set < Point2D > [ ] set = Geometry . getCardinalIntersects ( path , new Point2DArray ( c , p ) ) ; final Point2DArray points = Geometry . removeInnerPoints ( c , set ) ; return ( points . size ( ) > 1 ) ? points . get ( 1 ) : null ; } catch ( final Exception e ) { return null ; } }
Finds the intersection of the connector s end segment on a path .