Android examples for java.lang:Math Trigonometric Function
Rotates p1 around p2 by angle degrees.
import android.graphics.PointF; import android.util.FloatMath; import android.view.MotionEvent; public class Main{ /**//from ww w . ja v a2s. com * Rotates p1 around p2 by angle degrees. * * @param p1 * @param p2 * @param angle */ public static void rotate(PointF p1, PointF p2, float angle) { float px = p1.x; float py = p1.y; float ox = p2.x; float oy = p2.y; p1.x = (FloatMath.cos(angle) * (px - ox) - FloatMath.sin(angle) * (py - oy) + ox); p1.y = (FloatMath.sin(angle) * (px - ox) + FloatMath.cos(angle) * (py - oy) + oy); } }