Page 1 of 1

Simple rotation.

Posted: Sat Apr 26, 2014 4:36 am
by cyberpunk8bit
What Im trying to do, is to get the rotation of the physics object, in either radians, or degrees(would prefer degrees).

Ive tried: (PhysObj=physics object referencing)

PhysObj.Orientation.Y
PhysObj.OrientationMatrix.M11 (m11,m12,m13)
PhysObj.OrientationMatrix.Up.Y (Forward.Y, Down.Y)
PhysObj.AngularMomentum.Y (returns momentum, but I want radians or degrees)

I know there are several hundred posts asking the same, but i'm still lost...
I dont know if it how im calling it? im just using each new created physics object in array as: Box[] toAdd = new Box[100]; which works great. just cant get the angle how I want.
other than this issue, really liking BePu physics..

Re: Simple rotation.

Posted: Sat Apr 26, 2014 4:26 pm
by Norbo
There is no single 'angle' which constitutes an orientation in 3d space. Choosing a single angle would imply some additional constraints about what was being measured. For example, if you knew an object was only able to rotate around the world up axis, that would leave only a single angular degree of freedom which could be represented by a single value.

You may be thinking of Euler angles, where three numbers represent an orientation by indicating incremental rotations. Orientation quaternions and matrices can be converted to Euler angles if you want, but the process is arbitrary and BEPUphysics doesn't provide any helpers for it. Also, the Euler angles representation has some nasty issues and things tend to get gross extremely quickly whenever any nontrivial interaction is required. That's why BEPUphysics never uses them.

If you're actually looking for the rate of rotation and not the orientation, then use AngularVelocity. That value has some useful properties: AngularVelocity.Length() is the speed of rotation in radians, and Vector3.Dot(axis, AngularVelocity) is the angular velocity around that particular axis in radians.

Re: Simple rotation.

Posted: Fri Aug 22, 2014 1:56 pm
by hunx
omg norbo thanks the angularvelocity works fine
i used something like this to test how it works and the object make just what i want(rotate)

Code: Select all

            if (KeyboardState.IsKeyDown(Keys.F))
                xfloat = 1f;
            else if (KeyboardState.IsKeyDown(Keys.H))
                xfloat = -1f;
            else
                xfloat = 0;
            space.Entities[1].AngularVelocity = new Vector3(space.Entities[1].AngularVelocity.X, xfloat, space.Entities[1].AngularVelocity.Z);
thanks for the tip