Matrix rotate around center


Last Updated:

  1. aminet73

    aminet73 Member This Topic's Starter

    Joined:
    Sep 25, 2009
    Messages:
    8
    Likes Received:
    0
    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 (Text):
    1. m.setRotate(77, 16, 16);
    2.  
    3. rotatedBitmap = Bitmap.createBitmap(orgBitmap, 0, 0, orgBitmap
    4.                 .getWidth(), orgBitmap.getHeight(), m, true);
     

    Advertisement
  2. NoSenseWorrying

    NoSenseWorrying Well-Known Member

    Joined:
    Nov 4, 2009
    Messages:
    56
    Likes Received:
    0
    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.
     
  3. saravians

    saravians New Member

    Joined:
    Oct 20, 2010
    Messages:
    1
    Likes Received:
    0



    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​
     

Share This Page

Loading...