You can figure it out by testing each segment of the rect against the line
for intersection.  Then test the intersection is within the bounding box of
the rect.

This function came from carto.net:

function
intersect2lines(line1x1,line1y1,line1x2,line1y2,line2x1,line2y1,line2x2,line2y2)
{
    //formula see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/
    var result = new Array();
    var denominator = (line2y2 - line2y1)*(line1x2 - line1x1) - (line2x2 -
line2x1)*(line1y2 - line1y1);
    if (denominator == 0) {
        alert("lines are parallel");
    }
    else {
        ua = ((line2x2 - line2x1)*(line1y1 - line2y1) - (line2y2 -
line2y1)*(line1x1 - line2x1)) / denominator;
        ub = ((line1x2 - line1x1)*(line1y1 - line2y1) - (line1y2 -
line1y1)*(line1x1 - line2x1)) / denominator;
    }
    result["x"] = line1x1 + ua * (line1x2 - line1x1);
    result["y"] = line1y1 + ua * (line1y2 - line1y1);
    return(result);
}



Stephen




On 5/10/07, shydisturbedboy <[EMAIL PROTECTED]> wrote:
>
>   let's say we have a line and a rect. the line passes through the rect.
> how will it know that the line intersected with the box?
>
>  
>


[Non-text portions of this message have been removed]



-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to