• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Matrix rotate around center

aminet73

Lurker
hi,

I'm trying to rotate a 32x32 bitmap around it's center. But when the 'transformation' is done, it looked like it didn't rotate around center. Anyone got a clue to what's wrong with the code below?

Code:
m.setRotate(77, 16, 16);

rotatedBitmap = Bitmap.createBitmap(orgBitmap, 0, 0, orgBitmap
                .getWidth(), orgBitmap.getHeight(), m, true);
 
hi,

I'm trying to rotate a 32x32 bitmap around it's center. But when the 'transformation' is done, it looked like it didn't rotate around center. Anyone got a clue to what's wrong with the code below?

Code:
m.setRotate(77, 16, 16);

rotatedBitmap = Bitmap.createBitmap(orgBitmap, 0, 0, orgBitmap
                .getWidth(), orgBitmap.getHeight(), m, true);

I've been struggling with this exact same problem.

I'm not sure what you're trying to accomplish, but here's what worked for me:
Leave all that code exactly how you have it (assuming you're drawing at 0, 0). The problem I found was actually with my onDraw function.
If you had code like mine, it initially looked like:
canvas.drawBitmap(rotatedBitmap, x, y, null);

Instead, I had to change it to:
canvas.drawBitmap(rotatedBitmap, x - rotatedBitmap.getWidth() / 2, y - rotatedBitmap.getHeight() / 2, null);

This effectively draws the image with its center on the coordinate, and thus rotating around the center.
 



How one can transform body coordinate (Roll Pitch Yaw) system to ENU (east North UP) coordinate system.
I am using HTC mobile sensor accelerometre and orientation sensors.
I want to transform Acceleration values from mobile Coordinate system to ENU system, and also after transformation how should i verify it whether the transformation is ok.
Right now I am using
Ir=[sin(Y)*cos(P);cos(Y)*cos(P);sin(P)]
Ip=[cos(R)*cos(Y)+sin(R)*sin(Y)*sin(P);-cos(R)*sin(Y)+sin(R)*cos(Y)*sin(P);-sin(R)*cos(P)]
Iy=[-sin(R)*cos(Y)+cos(R)*sin(Y)*sin(P);sin(R)*sin(Y)+c os(R)*cos(Y)*sin(P);-cos(R)*cos(P)]
R=[Ir Ip Iy];
Ar=R*Ab
where Ab is the acceleration in body coordinate system and Ar is in ENU system. I want to verify whether is it right ? and if right How i can verify the results. I mean what value of my Ar should be (its z component shoud be maximum?)?


regards

ravi​
 
Back
Top Bottom