get angle in b2Mat22

Hello. It would be desirable to find out how to make function "Get" that from class "b2Mat22" to return "angle:Number" ❓

I from Russia, therefore do not take offence at illiteracy
Hi Freeeeeeeman,

I assume you're using the Flash version?
If so, something like this should do:

Code:
public function GetAngle(){
     return Math.atan2(col1.y,col1.x);
}

Just add that somewhere in b2Mat22.as
Otherwise I'm sure you can translate it to c++.

Hope that helps,
-Matt
It works not how it is necessary.
It is necessary to me, that MovieClip could turned completely, and it looked is realistic.
See at how the ball slides on a surface.
Hi Freeeeeeeman,

As far as I know there's nothing wrong with that function, should return the rotation of the matrix in radians.
I assume you're converting it to degrees, because if you were using radians on the MovieClip it would rotate much less.

Can you post all the code you're using to set the MovieClips rotation so I can check if something else might be wrong?

Thanks,
-Matt
Hi, skatehead. I use an example "TestBed", but I add in function "DrawShape", which in "Test.as" the code:
Code:
                 //======================
      // Draw Shape
      //======================
      public function DrawShape(shape:b2Shape) {
         switch (shape.m_type) {
            case b2Shape.e_circleShape :
               {
                  var circle:b2CircleShape = shape as b2CircleShape;
                  var pos:b2Vec2 = circle.m_position;
                  var r:Number = circle.m_radius;
                  var k_segments:Number = 16.0;
                  var k_increment:Number = 2.0 * Math.PI / k_segments;
                  m_sprite.graphics.lineStyle(1,0xffffff,1);
                  m_sprite.graphics.moveTo((pos.x + r) * m_physScale, (pos.y) * m_physScale);
                  var theta:Number = 0.0;

//=========================my_code================================

                  var mc_1:MovieClip = new c1();
                  mc_1.name = "mc_1";
                  m_sprite.addChild(mc_1);
                  mc_1.x = (pos.x) * m_physScale;
                  mc_1.y = (pos.y) * m_physScale;
                  mc_1.height=r*2*m_physScale;
                  mc_1.width=r*2*m_physScale;
                  mc_1.rotation=circle.m_R.GetAngle()*m_physScale;

//===============================================================


                             //bla-bla-bla...


                              }
         }
      }



In attachments the full project that i here did not write.
Hi Freeman,

The problem is this line here:
Code:
mc_1.rotation=circle.m_R.GetAngle()*m_physScale;

GetAngle() returns the angle in radians, you don't need to multiply it by m_physScale, but you do need to convert it to degrees.

So changing it to the following should do the trick.
Code:
mc_1.rotation=circle.m_R.GetAngle()*(180.0/Math.PI);

If you don't know about radians, you might want to read up on them, there isn't much to know but it's important to understand for situations like this one.
http://en.wikipedia.org/wiki/Radian
Many thanks! It really works!

Original thread: https://box2d.org/forum/viewtopic.php?t=181