I'm building a svg graph by using php.
I cannot find out how to determine if two elements intersect, for instance a line (path) and rectangle (rect)
<rect
style="opacity:0.5;fill:#ff0000;fill-opacity:1;stroke:#808080;stroke-width:1px"
id="rectangle"
width="40"
height="35"
x="57"
y="50" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 114,50 C 65,99 65,99 65,99"
id="line" />
or two rectangles
<rect
y="50"
x="57"
height="35"
width="40"
id="rectangle"
style="opacity:0.5;fill:#ff0000;fill-opacity:1;stroke:#808080;stroke-width:1px" />
<rect
y="58.92128"
x="72.528419"
height="39"
width="39"
id="rect2879"
style="opacity:0.5;fill:#00ff00;fill-opacity:1;stroke:#808080;stroke-width:1px" />
I'm looking for a mathematical formula or code example in any language.