FlorisSteenkamp / MAT

Medial Axis Transform - Library
119 stars 23 forks source link

Identify better terminating 3 prong #40

Open Gautam2010 opened 3 months ago

Gautam2010 commented 3 months ago

Trying to identify terminating point of the fonts svg

getProngCount(cpNode) == 3 && isTerminating(cpNode) && !cpNode.isHoleClosing

With above I am getting some valid result but in some cases i.e "A" is not valid since red marked should not be considered as it is hole closing terminating point.

image

Is there a better way to find?

FlorisSteenkamp commented 3 months ago

What you're doing looks about right. I don't think I understand 100%; you're sure the red marked is hole closing? It looks much like the other blue circles to me.

I typically use the demo to identify special points. Could you explain why the red marked should not be considered terminating?

FlorisSteenkamp commented 3 months ago

Thinking a bit about it, do you mean because they're on a loop containing a hole closer? In that case it might be better to send me the letters so I can test it rather than thumb-sucking the correct code.

Also, are the two circles correct that is not strictly terminating, e.g. the top left circle on the F and the one on the G? There should be an easy way to eliminate them also if needed?

Gautam2010 commented 3 months ago

@FlorisSteenkamp

For instance, the character "A" should only have 2 terminating points, ignoring the red-marked points since they have no further prongs.

image

The examples for "F" and "H" work as expected, with proper identification of terminating points.

However, with the character "G", the red-marked points are incorrectly considered terminating points even though they have further branches. These should be ignored.

image

How can I correctly identify the terminating points without considering the red-marked points?

FlorisSteenkamp commented 3 months ago

Please send me the letters in any format (maybe by pasting the SVG in a comment) and I'll whip up something that might work. I'm still not 100% clear why the top left circle on the F should be considered terminating though as it's part of a path to the top right circle? I'm assuming you're using the SAT on these shapes as well?

Gautam2010 commented 3 months ago

Yes you are right even top left circle on the F should be considered terminating. Here is svg path of the fonts

M 68.07 -8.71 L 63.1 -8.71 L 63.1 -13.72 L 74.58 -13.72 L 74.58 -3.46 A 34.334 34.334 0 0 1 72.407 -2.083 Q 71.303 -1.444 70.299 -0.996 A 15.006 15.006 0 0 1 68.75 -0.4 A 15.927 15.927 0 0 1 66.193 0.178 Q 64.602 0.41 62.74 0.41 A 20.559 20.559 0 0 1 59.868 0.221 Q 58.381 0.011 57.148 -0.433 A 10.135 10.135 0 0 1 55.76 -1.05 A 9.977 9.977 0 0 1 51.664 -5.221 A 12.093 12.093 0 0 1 51.57 -5.4 A 13.401 13.401 0 0 1 50.235 -9.776 A 17.078 17.078 0 0 1 50.09 -12.03 A 16.113 16.113 0 0 1 50.446 -15.492 A 12.443 12.443 0 0 1 51.71 -18.88 Q 53.34 -21.79 56.47 -23.3 Q 58.91 -24.46 63.05 -24.46 A 35.43 35.43 0 0 1 65.135 -24.403 Q 67.066 -24.289 68.353 -23.945 A 7.69 7.69 0 0 1 69.01 -23.74 A 7.785 7.785 0 0 1 71.779 -22.042 A 7.57 7.57 0 0 1 72.29 -21.5 A 8.795 8.795 0 0 1 73.609 -19.417 A 11.839 11.839 0 0 1 74.25 -17.65 L 67.09 -16.37 Q 66.64 -17.74 65.58 -18.46 A 3.917 3.917 0 0 0 64.266 -19.03 Q 63.737 -19.157 63.121 -19.176 A 7.19 7.19 0 0 0 62.89 -19.18 A 5.693 5.693 0 0 0 61.096 -18.91 A 4.639 4.639 0 0 0 58.99 -17.48 A 5.146 5.146 0 0 0 58.085 -15.871 Q 57.54 -14.361 57.54 -12.11 A 16.465 16.465 0 0 0 57.644 -10.191 Q 57.885 -8.139 58.69 -6.945 A 4.078 4.078 0 0 0 59.01 -6.53 Q 60.47 -4.86 63.1 -4.86 A 7.798 7.798 0 0 0 65.462 -5.214 A 7.418 7.418 0 0 0 65.48 -5.22 A 9.077 9.077 0 0 0 66.374 -5.562 Q 67.158 -5.906 68.07 -6.45 L 68.07 -8.71 Z M 79.03 0 L 79.03 -24.05 L 86.46 -24.05 L 86.46 -15.64 L 94.58 -15.64 L 94.58 -24.05 L 102.05 -24.05 L 102.05 0 L 94.58 0 L 94.58 -9.73 L 86.46 -9.73 L 86.46 0 L 79.03 0 Z M 28.63 0 L 28.63 -24.05 L 47 -24.05 L 47 -18.88 L 36.09 -18.88 L 36.09 -14.68 L 45.41 -14.68 L 45.41 -9.83 L 36.09 -9.83 L 36.09 0 L 28.63 0 Z M 18.44 0 L 17.26 -3.97 L 8.79 -3.97 L 7.63 0 L 0.03 0 L 9.07 -24.05 L 17.18 -24.05 L 26.22 0 L 18.44 0 Z M 10.4 -9.17 L 15.7 -9.17 L 13.04 -17.82 L 10.4 -9.17 Z