use of pythagoras.util.NoninvertibleTransformException in project playn by threerings.
the class GroupLayerImpl method hitTest.
public Layer hitTest(GroupLayer self, Point point) {
float x = point.x, y = point.y;
boolean sawInteractiveChild = false;
// we check back to front as children are ordered "lowest" first
for (int ii = children.size() - 1; ii >= 0; ii--) {
L child = children.get(ii);
// ignore non-interactive children
if (!child.interactive())
continue;
// note that we saw an interactive child
sawInteractiveChild = true;
// ignore invisible children
if (!child.visible())
continue;
try {
// transform the point into the child's coordinate system
child.transform().inverseTransform(point.set(x, y), point);
point.x += child.originX();
point.y += child.originY();
Layer l = child.hitTest(point);
if (l != null)
return l;
} catch (NoninvertibleTransformException nte) {
// Degenerate transform means no hit
continue;
}
}
// interactive children have been deactivated or removed
if (!sawInteractiveChild && !((AbstractLayer) self).hasInteractors())
self.setInteractive(false);
return null;
}
use of pythagoras.util.NoninvertibleTransformException in project playn by threerings.
the class HtmlInternalTransform method rotation.
@Override
public float rotation() {
// use the iterative polar decomposition algorithm described by Ken Shoemake:
// http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
// start with the contents of the upper 2x2 portion of the matrix
float n00 = m00(), n10 = m10();
float n01 = m01(), n11 = m11();
for (int ii = 0; ii < 10; ii++) {
// store the results of the previous iteration
float o00 = n00, o10 = n10;
float o01 = n01, o11 = n11;
// compute average of the matrix with its inverse transpose
float det = o00 * o11 - o10 * o01;
if (Math.abs(det) == 0f) {
// determinant is zero; matrix is not invertible
throw new NoninvertibleTransformException(this.toString());
}
float hrdet = 0.5f / det;
n00 = +o11 * hrdet + o00 * 0.5f;
n10 = -o01 * hrdet + o10 * 0.5f;
n01 = -o10 * hrdet + o01 * 0.5f;
n11 = +o00 * hrdet + o11 * 0.5f;
// compute the difference; if it's small enough, we're done
float d00 = n00 - o00, d10 = n10 - o10;
float d01 = n01 - o01, d11 = n11 - o11;
if (d00 * d00 + d10 * d10 + d01 * d01 + d11 * d11 < FloatMath.EPSILON) {
break;
}
}
// now that we have a nice orthogonal matrix, we can extract the rotation
return FloatMath.atan2(n01, n00);
}
Aggregations