1. Download our Official Android App: Forums for Android!

Apps Matrix rotate around center

Discussion in 'Android Development' started by aminet73, Mar 24, 2010.

  1. aminet73

    aminet73 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Sep 25, 2009

    Sep 25, 2009
    8
    0
    5
    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

    Rank:
    None
    Points:
    35
    Posts:
    56
    Joined:
    Nov 4, 2009

    Nov 4, 2009
    56
    0
    35
    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Oct 20, 2010

    Oct 20, 2010
    1
    0
    5



    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...