Q:

Drawing a rotating triangle

I want to fill a triangle in Android using the Canvas class. The way I am doing currently works but is very laggy. I wanted to know if anybody has a faster way of doing it than my way. Thanks!
My code:
public void rotate(float angle){
    if(neighbour == null)
        return;
    path.reset();
    Point origin = rotatePoint(neighbour.getX() + 64, neighbour.getY() + 128 + 16, neighbour.getX() + 64, neighbour.getY() + 64, angle);
    Point a = rotatePoint(neighbour.getX() + 64, neighbour.getY() + 128 + neighbour.getWidth() + neighbour.getHeight(), neighbour.getX() + 64, neighbour.getY() + 64, angle - 15);
    Point b = rotatePoint(neighbour.getX() + 64, neighbour.getY() + 128 + neighbour.getWidth() + neighbour.getHeight(), neighbour.getX() + 64, neighbour.getY() + 64, angle + 15);
    path.moveTo(origin.x, origin.y);
    path.lineTo(a.x, a.y);
    path.lineTo(b.x, b.y);
}

neighbour is just a class that holds x and y values.
Rotate point method:
private Point rotatePoint(float x, float y, float px, float py, float angle){
    float s = (float)Math.sin(Math.toRadians(angle));
    float c = (float)Math.cos(Math.toRadians(angle));

    x -= px;
    y -= py;

    float xnew = x * c - y * s;
    float ynew = x * s + y * c;

    x = xnew + px;
    y = ynew + py;
    return new Point((int)x, (int)y);
}

This triangle will be rotated quite frequently so I need a efficient way of doing it.

A:

You can just draw the triangle always with the same path, but before drawing the path rotate the canvas to the desired rotation angle.
canvas.save();
canvas.rotate(degrees);
//draw your triangle here
canvas.restore();

There is also a
canvas.rotate(degrees, x, y);

if you need to give it a pivot point.

