I have the following code and despite numerous attempts to get it to evaluate properly, I can't get it to work. I have a work around to check each item individually (in which case it works) but the fact that I can write what appears to be a simple math statement and it doesn't work is troubling.
I've checked the values of the points and they are well within the rectangle it will return false. If I check each individually, it will evaluate them properly and I get a true value.
Thanks in advance for your time!
public static boolean checkIfPointInRectangle(RectF rect, float canvasRotateAngle, float objRotationAngle, int sketchPadHeight, int sketchPadWidth, float pointX, float pointY) {
float[] points = new float[] { pointX, pointY }; // Transform the points to the current rotation Matrix transform = new Matrix(); transform.setRotate(objRotationAngle - canvasRotateAngle, sketchPadWidth / 2, sketchPadHeight / 2); transform.mapPoints(points); if(((rect.left <= points[0]) && (points[0] < rect.right) && (rect.top <= points[1]) && (points[1] < rect.bottom))){ return true; } else{ return false; } }
Aucun commentaire:
Enregistrer un commentaire