Code: Select all
float maxDistSquared = pow(0.05 * getScaleFactor(), 2);
Code: Select all
log(maxDistSquared) = 2*log(scaleFactor)
maxDistSquared = scaleFactor^2
After fixing it, I found another problem. Even if the constraints are located exactly at the same point, if I increase zoom enough, their icons separate. The reason for this was related to the Z coordinate of icons. For some reason icons can have either z=0.009 or z=0.018. Icon coordinates are in sketch coordinate system, not global. For two icons i and j I got positions and squared distance between them
Code: Select all
i.pos(-20.000000,20.000000,0.009000),j.pos(-20.000000,20.000000,0.018000),distsquared(0.000081)
Now to the jittering problem. It happens when icons are merged and I move one of the constraints. The reason is that one of the constraint icons in Coin gets reused as a merged icon. Its image is changed, but position stays the same. So, merged icon is placed at the same place as one of the original icons. First, average position of icons is calculated. The icon closest to the average position gets chosen. As you move the constraint, average position changes and, which icon is closest to the average position, also might change. The jitter is the result of this change, it switches from being in the position of one icon to the position of the other. The simplest solution is to take the first icon and use its position for the position of the merged icon. It would be more complicated to fix it by using any other solution, e.g. creating separate icon for the merged constraints or change position of the chosen icon to be the actual average position. The result looks nicer then the original.