Package com.ngt.jopenmetaverse.shared.types

Examples of com.ngt.jopenmetaverse.shared.types.Quaternion


            Utils.UInt16ToFloat(block.Data, pos, -64.0f, 64.0f),
            Utils.UInt16ToFloat(block.Data, pos + 2, -64.0f, 64.0f),
            Utils.UInt16ToFloat(block.Data, pos + 4, -64.0f, 64.0f));
        pos += 6;
        // Rotation (theta)
        update.Rotation = new Quaternion(
            Utils.UInt16ToFloat(block.Data, pos, -1.0f, 1.0f),
            Utils.UInt16ToFloat(block.Data, pos + 2, -1.0f, 1.0f),
            Utils.UInt16ToFloat(block.Data, pos + 4, -1.0f, 1.0f),
            Utils.UInt16ToFloat(block.Data, pos + 6, -1.0f, 1.0f));
        pos += 8;
View Full Code Here


        i += 12;
        // Position
        prim.Position = new Vector3(block.Data, i);
        i += 12;
        // Rotation
        prim.Rotation = new Quaternion(block.Data, i, true);
        i += 12;
        // Compressed flags
        //EnumSet<CompressedFlags>
        long flags = Utils.bytesToUIntLit(block.Data, i);
        i += 4;
View Full Code Here

              if (omega > 0.00001f)
              {
                omega = (float)Math.sqrt(omega);
                float angle = omega * adjSeconds;
                angVel = Vector3.multiply(angVel, 1.0f / omega);
                Quaternion dQ = Quaternion.createFromAxisAngle(angVel, angle);

                prim.Rotation = Quaternion.multiply(prim.Rotation, dQ);
              }
              //endregion Angular Velocity

View Full Code Here

  /// <param name="target">Region coordinates to turn toward</param>
  public boolean TurnToward(Vector3 target)
  {
    if (Client.settings.SEND_AGENT_UPDATES)
    {
      Quaternion parentRot = Quaternion.Identity;

      if (Client.self.getSittingOn() > 0)
      {
        if (!Client.network.getCurrentSim().ObjectsPrimitives.containsKey(Client.self.getSittingOn()))
        {
          JLogger.warn("Attempted TurnToward but parent prim is not in dictionary");
          return false;
        }
        else parentRot = Client.network.getCurrentSim().ObjectsPrimitives.get(Client.self.getSittingOn()).Rotation;
      }

      Quaternion between = Vector3.rotationBetween(Vector3.UnitX, Vector3.normalize(Vector3.subtract(target, Client.self.getSimPosition())));
      Quaternion rot = Quaternion.multiply(between, Quaternion.divide(Quaternion.Identity, parentRot));

      BodyRotation = rot;
      HeadRotation = rot;
      Camera.LookAt(Client.self.getSimPosition(), target);
View Full Code Here

           zAxis = Z_AXIS;
       }

       public void Rotate(float angle, Vector3 rotationAxis) throws Exception
       {
           Quaternion q = Quaternion.createFromAxisAngle(rotationAxis, angle);
           Rotate(q);
       }
View Full Code Here

               throw new Exception("Non-finite in CoordinateFrame.Rotate()");
       }

       public void Roll(float angle) throws Exception
       {
           Quaternion q = Quaternion.createFromAxisAngle(xAxis, angle);
           Matrix4 m = Matrix4.createFromQuaternion(q);
           Rotate(m);

           if (!yAxis.isFinite() || !zAxis.isFinite())
               throw new Exception("Non-finite in CoordinateFrame.Roll()");
View Full Code Here

               throw new Exception("Non-finite in CoordinateFrame.Roll()");
       }

       public void Pitch(float angle) throws Exception
       {
           Quaternion q = Quaternion.createFromAxisAngle(yAxis, angle);
           Matrix4 m = Matrix4.createFromQuaternion(q);
           Rotate(m);

           if (!xAxis.isFinite() || !zAxis.isFinite())
               throw new Exception("Non-finite in CoordinateFrame.Pitch()");
View Full Code Here

               throw new Exception("Non-finite in CoordinateFrame.Pitch()");
       }

       public void Yaw(float angle) throws Exception
       {
           Quaternion q = Quaternion.createFromAxisAngle(zAxis, angle);
           Matrix4 m = Matrix4.createFromQuaternion(q);
           Rotate(m);

           if (!xAxis.isFinite() || !yAxis.isFinite())
               throw new Exception("Non-finite in CoordinateFrame.Yaw()");
View Full Code Here

  }

  @Test
  public void Quaternions()
  {
    Quaternion a = new Quaternion(1, 0, 0, 0);
    Quaternion b = new Quaternion(1, 0, 0, 0);

    Assert.assertTrue("Quaternion comparison operator failed", a.equals(b));

    Quaternion expected = new Quaternion(0, 0, 0, -1);
    Quaternion result = Quaternion.multiply(a , b);

    Assert.assertTrue( a.toString() + " * " + b.toString() + " produced " + result.toString() +
        " instead of " + expected.toString(), result.equals(expected));

    a = new Quaternion(1, 0, 0, 0);
    b = new Quaternion(0, 1, 0, 0);
    expected = new Quaternion(0, 0, 1, 0);
    result = Quaternion.multiply(a , b);

    Assert.assertTrue(a.toString() + " * " + b.toString() + " produced " + result.toString() +
        " instead of " + expected.toString(), result.equals(expected));

    a = new Quaternion(0, 0, 1, 0);
    b = new Quaternion(0, 1, 0, 0);
    expected = new Quaternion(-1, 0, 0, 0);
    result = Quaternion.multiply(a , b);

    Assert.assertTrue(a.toString() + " * " + b.toString() + " produced " + result.toString() +
        " instead of " + expected.toString(), result.equals(expected));
  }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.types.Quaternion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.