I am trying to find out whether to geometrical shapes overlap. This is based on an SVG-file. The following is an example:
Group 1:
<g transform="matrix(1.0 0.0 0.0 1.0 257.0 124.95)">
<g transform="matrix(1.7880859 0.0 0.0 0.9476929 -0.05 0.0)">
<path d="M 18.9 8.15 L -18.85 8.15 L -18.85 -8.1 L 18.9 -8.1 L 18.9 8.15 Z"/>
</g>
</g>
Group 2:
<g transform="matrix(1.0 0.0 0.0 1.0 244.05 85.95)">
<path transform="matrix(0.009765625 0.0 0.0 0.009765625 64.3499984741211 9.0)" d="M 328.0 0.0 L 328.0 -176.0 L 12.0 -176.0 L 12.0 -260.0 L 348.0 -728.0 L 420.0 -728.0 L 420.0 -260.0 L 520.0 -260.0 L 520.0 -176.0 L 420.0 -176.0 L 420.0 0.0 L 328.0 0.0 Z M 420.0 0.0 L 420.0 0.0 Z M 328.0 -260.0 L 328.0 -576.0 L 101.0 -260.0 L 328.0 -260.0 Z M 101.0 -260.0 L 101.0 -260.0 Z"/>
</g>
These items are in svg format. What it means is the following:
- The outer element (
g)is a group which contains some shapes. - A group can contain other groups (such as in the first example
- a group has a matrix transformation which consists of 6 values: 1: x scale 2: y skew 3: x skew 4: y scale 5: x translate 6: y translate
So, for the first item that means that x is scaled by 1.0, y is scaled by one, x is translated by 257 and y is translated by 124.95
- a path also has a matrix transform which abides to the same rules
- a path has a value (d) which defines how it's drawn. It works by drawing the line following the instructions (shown by a letter). The following instructions are provided:
L: Line to
M: Move to
C: curve to
Z: close path
Now, given these two groups, how can I find out whether they overlap or not?
What I have tried so far is establishing the left most point and the top most point of each group. I did this by taking the total translation and then looking for the left most point in the path and adding these together. However, I don't know how to take the curve into consideration and the results are incorrect (based on manual inspection).
Also, once I have these, how would I go checking whether they overlap?
I'm sorry if this question is a bit unclear (or not fit for math.stackexchange).