I want an arrow to point from where the user touches down on the screen to where they lift off and I want it to update as they move there finger across the screen
Using java Syntax Highlighting
- m = new Matrix();
- float postScaleY = (float)(targetArrowSize/arrowHeight);
- //arrowHeight is the height of the image targetArrow size is the wanted size
- m.postScale(1,postScaleY);
- // fromLocation is the touch down and targetArrowLocation is the up or move point
- double x = (targetArrowLocation.x - fromLocation.x);
- double y = (targetArrowLocation.y - fromLocation.y);
- double theta = Math.acos( y /Math.sqrt( Math.pow(x, 2) +Math.pow(y, 2) ) );
- m.postRotate( (float) Math.toDegrees(theta) );
- m.postTranslate(fromLocation.x - offsetX, fromLocation.y - offsetY);
- invalidate();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
This works if the fromLocation.x is to the right of the targetArrowLocation but if this isnt the case it draws the arrow pointing to the corresponding point on the opposite side of the screen... so the arrow always points left..
I think that if I could do a reflection across the y-axis it would work, so if anyone can tell me how to do that I can try it... but there must be a way to get the math right... Any Ideas?
without any matrix being applied the arrow points down into the positive Y


