| 
  | 
Roman Reiner wrote:
> There you go. Not really simpler but it wont give you divide by zero errors.
> 
> #macro LineIntersect2D(A,B,C,D)
>   #local det = (D.y-C.y)*(B.x-A.x)-(D.x-C.x)*(B.y-A.y);
>   #local c = (D.x-C.x)*(A.y-C.y)-(D.y-C.y)*(A.x-C.x);
>   #if(det != 0)
>     #local slope_intercept_x = A.x+c/det*(B.x-A.x);
>     #local slope_intercept_y = A.y+c/det*(B.y-A.y);
>   #else
>     #if(c != 0)
>       //handle parallel case
>     #else
>       //handle coincident case
>     #end
>   #end
>   <slope_intercept_x, slope_intercept_y>
> #end
Thanks! I'll test it out. For the parallel and coincident cases, I 
suppose just returning <0,0> would suffice?
 
 Post a reply to this message 
 | 
  |