FromAxisAngle() public method

Set this quaternion from a normalized axis and an angle of rotation around that axis
public FromAxisAngle ( Vector3f axis, float angle ) : void
axis Vector3f Axis of rotation
angle float Angle of rotation
return void
Esempio n. 1
0
 public void Rotate(float angle, Vector3f rotationAxis)
 {
     Quaternionf q = new Quaternionf();
     q.FromAxisAngle(rotationAxis, angle);
     Rotate(q);
 }
Esempio n. 2
0
        public void Yaw(float angle)
        {
            Quaternionf q = new Quaternionf();
            q.FromAxisAngle(zAxis, angle);
            Matrix4f m = new Matrix4f();
            m.FromQuaternion(q);
            Rotate(m);

            if (!xAxis.IsFinite() || !yAxis.IsFinite())
                throw new Exception("Non-finite in CoordinateFrame.Yaw()");
        }
Esempio n. 3
0
        protected void InterpolationTimer_Elapsed(object obj)
        {
            if (Client.Network.Connected)
            {
                int interval = Environment.TickCount - Client.Self.lastInterpolation;
                float seconds = (float)interval / 1000f;

                // Iterate through all of the simulators
                lock (Client.Network.Simulators)
                {
                    for (int i = 0; i < Client.Network.Simulators.Count; i++)
                    {
                        float adjSeconds = seconds * Client.Network.Simulators[i].Stats.Dilation;

                        // Iterate through all of this sims avatars
                        Client.Network.Simulators[i].ObjectsAvatars.ForEach(
                            delegate(Avatar avatar)
                            {
                                #region Linear Motion
                                // Only do movement interpolation (extrapolation) when there is a non-zero velocity but 
                                // no acceleration
                                if (avatar.Acceleration != Vector3f.Zero && avatar.Velocity == Vector3f.Zero)
                                {
                                    avatar.Position += (avatar.Velocity + avatar.Acceleration *
                                        (0.5f * (adjSeconds - HAVOK_TIMESTEP))) * adjSeconds;
                                    avatar.Velocity += avatar.Acceleration * adjSeconds;
                                }
                                #endregion Linear Motion
                            }
                        );

                        // Iterate through all of this sims primitives
                        Client.Network.Simulators[i].ObjectsPrimitives.ForEach(
                            delegate(Primitive prim)
                            {
                                if (prim.Joint == JointType.Invalid)
                                {
                                    #region Angular Velocity
                                    Vector3f angVel = prim.AngularVelocity;
                                    float omega = angVel.LengthSquared();

                                    if (omega > 0.00001f)
                                    {
                                        omega = (float)Math.Sqrt(omega);
                                        float angle = omega * adjSeconds;
                                        angVel *= 1.0f / omega;
                                        Quaternionf dQ = new Quaternionf();
                                        dQ.FromAxisAngle(angVel, angle);

                                        prim.Rotation *= dQ;
                                    }
                                    #endregion Angular Velocity

                                    #region Linear Motion
                                    // Only do movement interpolation (extrapolation) when there is a non-zero velocity but 
                                    // no acceleration
                                    if (prim.Acceleration != Vector3f.Zero && prim.Velocity == Vector3f.Zero)
                                    {
                                        prim.Position += (prim.Velocity + prim.Acceleration *
                                            (0.5f * (adjSeconds - HAVOK_TIMESTEP))) * adjSeconds;
                                        prim.Velocity += prim.Acceleration * adjSeconds;
                                    }
                                    #endregion Linear Motion
                                }
                                else if (prim.Joint == JointType.Hinge)
                                {
                                    //FIXME: Hinge movement extrapolation
                                }
                                else if (prim.Joint == JointType.Point)
                                {
                                    //FIXME: Point movement extrapolation
                                }
                                else
                                {
                                    Logger.Log("Unhandled joint type " + prim.Joint, Helpers.LogLevel.Warning, Client);
                                }
                            }
                        );
                    }
                }

                // Make sure the last interpolated time is always updated
                Client.Self.lastInterpolation = Environment.TickCount;
            }
        }