本文整理汇总了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);
}
示例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));
}
示例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;
}
示例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;
}
}
示例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));
}
示例6: Rotate
void Rotate(Quaternion q)
{
Vector3 r = new Vector3();
float a=0;
q.ToAngleAxis(out a,out r);
transform.Rotate(r, a);
}
示例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();
}
}
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}