当前位置: 首页>>代码示例>>C#>>正文


C# Quaternion.ToAngleAxis方法代码示例

本文整理汇总了C#中UnityEngine.Quaternion.ToAngleAxis方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.ToAngleAxis方法的具体用法?C# Quaternion.ToAngleAxis怎么用?C# Quaternion.ToAngleAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Quaternion的用法示例。


在下文中一共展示了Quaternion.ToAngleAxis方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetRotation

 public void SetRotation(Quaternion rotation)
 {
     Vector3 axis;
     float angle;
     rotation.ToAngleAxis(out angle, out axis);
     EffekseerSystem.Plugin.EffekseerSetRotation(handle, axis.x, axis.y, axis.z, angle * Mathf.Deg2Rad);
 }
开发者ID:saihe,项目名称:Effekseer,代码行数:7,代码来源:EffekseerSystem.cs

示例2: ToString

        /// <summary>
        /// Converts the data to a string value
        /// </summary>
        /// <returns>The string.</returns>
        /// <param name="rInput">Value to convert</param>
        public static string ToString(Quaternion rInput)
        {
            Vector3 lEuler = rInput.eulerAngles;

            float lAngle = 0f;
            Vector3 lAxis = Vector3.zero;
            rInput.ToAngleAxis(out lAngle, out lAxis);

            return String.Format("[p:{0:f4} y:{1:f4} r:{2:f4} x:{3:f7} y:{4:f7} z:{5:f7} w:{6:f7} angle:{7:f7} axis:{8}]", lEuler.x, lEuler.y, lEuler.z, rInput.x, rInput.y, rInput.z, rInput.w, lAngle, ToString(lAxis));
        }
开发者ID:bmjoy,项目名称:Immortal,代码行数:15,代码来源:StringHelper.cs

示例3: ToAngularVelocity

    public static Vector3 ToAngularVelocity(Quaternion deltaRotation, float deltaTime) {
      Vector3 deltaAxis;
      float deltaAngle;
      deltaRotation.ToAngleAxis(out deltaAngle, out deltaAxis);

      if (float.IsInfinity(deltaAxis.x)) {
        deltaAxis = Vector3.zero;
        deltaAngle = 0;
      }

      if (deltaAngle > 180) {
        deltaAngle -= 360.0f;
      }

      return deltaAxis * deltaAngle * Mathf.Deg2Rad / deltaTime;
    }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:16,代码来源:PhysicsUtility.cs

示例4: Update

    // Update is called once per frame
    // TODO: use fixedupdate for rigidbody manip
    void Update()
    {
        //people recommend doing rigidbody stuff with fixedupdate?
        if(attachedWand && currentlyInteracting)
        {
            posDelta = attachedWand.transform.position - interactionPoint.position;
            this.rigidbody.velocity = posDelta * velocityFactor * Time.fixedDeltaTime;

            rotationDelta = attachedWand.transform.rotation * Quaternion.Inverse(interactionPoint.rotation);
            rotationDelta.ToAngleAxis(out angle, out axis);

            if(angle > 180) // if you rotate your hand quickly enough, there are two ways to rotate towards
            {
                angle -= 360;
            }

            this.rigidbody.angularVelocity = (Time.fixedDeltaTime * angle * axis) * rotationFactor;

        }
    }
开发者ID:Rosstin,项目名称:BreakupSimulator201606,代码行数:22,代码来源:InteractableItem.cs

示例5: UpdateRotation

        public void UpdateRotation(Vector3 startPos, Quaternion referenceTransform, Quaternion inputQuat)
        {
            Vector3 vec3 = new Vector3(3f, 3f, 3f);
            Vector3 vec15 = new Vector3(1.5f, 1.5f, 1.5f);
            Vector3 vec05 = new Vector3(0.5f, 0.5f, 0.5f);
            Vector3 vec025 = new Vector3(0.25f, 0.25f, 0.25f);
            float inputTheta;
            Vector3 inputAxis;
            inputQuat.ToAngleAxis(out inputTheta, out inputAxis);
            //Rotate so unrotated is up.
            Vector3 upVector = FlightGlobals.upAxis;
            //Theta stuff
            Vector3 thetaStart = startPos + (Vector3.Scale(referenceTransform * inputAxis, vec15));
            Vector3 refDirection = Vector3.up;
            float thetaX = Mathf.Sin(inputTheta * Mathf.Deg2Rad);
            float thetaY = Mathf.Cos(inputTheta * Mathf.Deg2Rad);
            Vector3 thetaDirection = new Vector3(thetaX, thetaY, 0f);


            axis.UpdatePosition(startPos, startPos + Vector3.Scale(referenceTransform * inputAxis, vec3));
            reference0.UpdatePosition(thetaStart, thetaStart + Vector3.Scale(referenceTransform * refDirection, vec025));
            theta.UpdatePosition(thetaStart, thetaStart + Vector3.Scale(referenceTransform * thetaDirection, vec05));
        }
开发者ID:Opice,项目名称:DarkMultiPlayer,代码行数:23,代码来源:3DDebug.cs

示例6: Rotate

 void Rotate(Quaternion q)
 {
     Vector3 r = new Vector3();
     float a=0;
     q.ToAngleAxis(out a,out r);
     transform.Rotate(r, a);
 }
开发者ID:cWalters2,项目名称:ShSoul,代码行数:7,代码来源:plSerenSword.cs

示例7: UpdateAnimation

    // fonction de mise à jour des données d'animation
    void UpdateAnimation()
    {
        // mise à jour de la tête de lecture de l'animation
        playhead = ((Time.time - start) * speed) / duration;

        // borner la position de la tête de lecture dans l'intervalle [0,1]
        playhead = playhead > 1.0f ? 1.0f : playhead < 0.0f ? 0.0f : playhead;

        // mise à jour des quaternions d'orientation par interpolation sphérique linéaire (slerp)
        yQuaternionCurrent = Quaternion.Slerp(yQuaternionFrom, yQuaternionTo, playhead);
        xQuaternionCurrent = Quaternion.Slerp(xQuaternionFrom, xQuaternionTo, playhead);

        // extraction de l'orientation du quaternion sous forme d'un axe de rotation et d'un angle
        yQuaternionCurrent.ToAngleAxis(out angle, out axis);

        // orienter le point de pivot en Y de l'oiseau
        pivotY.transform.Rotate(axis, angle, Space.Self);

        // réinitialiser l'orientation du point de pivot en X, pour le ramener à l'orientation du parent hiérarchique (point de pivot en Y)
        pivotX.transform.rotation = Quaternion.identity;

        // extraction de l'orientation du quaternion sous forme d'un axe de rotation et d'un angle
        yQuaternionCurrent.ToAngleAxis(out angle, out axis);

        // orienter le point de pivot en X de l'oiseau
        pivotX.transform.Rotate(axis, angle, Space.Self);

        // extraction de l'orientation du quaternion sous forme d'un axe de rotation et d'un angle
        xQuaternionCurrent.ToAngleAxis(out angle,out axis);

        // orienter le point de pivot en X de l'oiseau
        pivotX.transform.Rotate(axis, angle, Space.Self);

        // valider si l'animaton est complétée
        if(playhead >= 1.0f)
        {
            // valider la direction de l'animation
            if(reverse)
            {
                reverse = false;
                animate = false;

                xQuaternionFrom = xQuaternionTo;
                yQuaternionFrom = yQuaternionTo;
            }
            else
            {
                // inverser l'animation
                reverse = true;

                xQuaternionFrom = xQuaternionTo;
                yQuaternionFrom = yQuaternionTo;

                xQuaternionTo = Quaternion.identity;
                yQuaternionTo = yQuaternionFrom;

                // réinitialiser les données d'animation
                Setup();
            }
        }
    }
开发者ID:philvoyer,项目名称:ANI2012A15,代码行数:62,代码来源:Engine.cs

示例8: rtuRotation

 static Quaternion rtuRotation(Quaternion q)
 {
     Vector3 v;
     float a;
     q.ToAngleAxis(out a, out v);
     return Quaternion.AngleAxis(-a, new Vector3(v.x, v.z, v.y));
 }
开发者ID:brett19,项目名称:RoseTwoPointOh,代码行数:7,代码来源:Main.cs

示例9: r2uRotation

 public static Quaternion r2uRotation(Quaternion q)
 {
     Vector3 axis;
     float angle;
     q.ToAngleAxis(out angle, out axis);
     return Quaternion.AngleAxis(angle, new Vector3(axis.x, axis.z, -axis.y));
 }
开发者ID:osROSE,项目名称:UnityRose,代码行数:7,代码来源:Utils.cs

示例10: Drag

 public void Drag(Vector3 position, Vector3 move, Quaternion rotate)
 {
     transform.Translate(move, Space.World);
     Vector3 axis;
     float angle;
     rotate.ToAngleAxis(out angle, out axis);
     transform.RotateAround(position, axis, angle);
 }
开发者ID:vildninja,项目名称:voxel,代码行数:8,代码来源:ChunkManager.cs

示例11: OrientationFromAngle

 //! Get orientation from old orientation and angle.
 private ja2.LookDirection OrientationFromAngle(Quaternion Orientation)
 {
     Vector3 vec;
     float angle;
     Orientation.ToAngleAxis(out angle, out vec);
     // Get number of 45 rotations
     float angle_count = (vec.y > 0 ? angle : 360 - angle) / 45;
     // Lower bound
     byte lower_bound = (byte)Mathf.FloorToInt(angle_count);
     // Compute new rotation look
     return (ja2.LookDirection)(((angle_count - lower_bound >= 0.5f ? lower_bound + 1 : lower_bound) % 8));
 }
开发者ID:Trigve,项目名称:ja2_unity,代码行数:13,代码来源:SoldierController.cs

示例12: ConvertRotation

        public static rotate ConvertRotation(Quaternion input)
        {
            rotate output = new rotate();

            Vector3 axis;
            float angle;
            input.ToAngleAxis(out angle, out axis);

            output.Values = new double[] { axis.x, axis.y, axis.z, angle };
            output.sid = "rotate";
            return output;
        }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:12,代码来源:MeshToCollada.cs

示例13: getHandEyeCalibration

        /**
         * Get hand-eye calibration in Unity coordinate system (left-handed)
         */
        public static void getHandEyeCalibration(out Vector3 translation, out Quaternion rotation, CameraType cameraType)
        {
            float[] res = new float[7];
            GCHandle arrayHandle = GCHandle.Alloc(res, GCHandleType.Pinned);
            IntPtr ptr = arrayHandle.AddrOfPinnedObject();
            getHandEyeCalibrationInternal(ptr, (int)cameraType);
            arrayHandle.Free();

            // To Unity coordinates
            translation = new Vector3(res[0], res[1], -res[2]);
            rotation = new Quaternion(res[3], res[4], res[5], res[6]);

            float angle;
            Vector3 axis;
            rotation.ToAngleAxis(out angle, out axis);
            axis.x *= -1;
            axis.y *= -1;
            rotation = Quaternion.AngleAxis(angle, axis);
        }
开发者ID:hqt08,项目名称:ARGame,代码行数:22,代码来源:MetaioSDKUnity.cs


注:本文中的UnityEngine.Quaternion.ToAngleAxis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。