本文整理汇总了C#中Quaternion.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.ToString方法的具体用法?C# Quaternion.ToString怎么用?C# Quaternion.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Quaternions
public void Quaternions()
{
Quaternion a = new Quaternion(1, 0, 0, 0);
Quaternion b = new Quaternion(1, 0, 0, 0);
Assert.IsTrue(a == b, "Quaternion comparison operator failed");
Quaternion expected = new Quaternion(0, 0, 0, -1);
Quaternion result = a * b;
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
" instead of " + expected.ToString());
a = new Quaternion(1, 0, 0, 0);
b = new Quaternion(0, 1, 0, 0);
expected = new Quaternion(0, 0, 1, 0);
result = a * b;
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
" instead of " + expected.ToString());
a = new Quaternion(0, 0, 1, 0);
b = new Quaternion(0, 1, 0, 0);
expected = new Quaternion(-1, 0, 0, 0);
result = a * b;
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
" instead of " + expected.ToString());
}
示例2: Member
public Member(string k, Transform t, Vector3 axisA, Vector3 axisB, Vector3 axisC)
{
key = k;
transform = t;
this.axisA = axisA;
this.axisB = axisB;
this.axisC = axisC;
if (transform == null) {
Debug.Log("WARNING: " + key + " member is null");
}
elapsed = 0;
time = 5;
defaultRotation = transform.localRotation;
initialRotation = defaultRotation;
goalRotation = defaultRotation;
Debug.Log("Create member " + key + " with rotation " + defaultRotation.ToString());
}
示例3: Update
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (0,Time.deltaTime* rotationSpeed,0));
//Debug.Log(Cardboard.SDK.HeadPose.Orientation.ToString());
//Debug.Log(Cardboard.SDK.Triggered.ToString());
if (Cardboard.SDK.Triggered) {
orbFollowsHead = !orbFollowsHead;
if (orbFollowsHead) {
cardboardRotationOffset = Cardboard.SDK.HeadPose.Orientation;
Debug.Log ("Saved Offset:" + cardboardRotationOffset.ToString ());
} else {
objectRotationOffset = transform.rotation;
}
}
if (orbFollowsHead) {
transform.rotation = Cardboard.SDK.HeadPose.Orientation;
transform.rotation *= Quaternion.Inverse (cardboardRotationOffset);
transform.rotation *= objectRotationOffset;
Debug.Log ("ObjectOffset:"+objectRotationOffset);
}
}
示例4: Quaternion_ToString_Test
public void Quaternion_ToString_Test()
{
var q = new Quaternion(0.1f, 0.22f, 0.333f, 0.4444f);
Assert.AreEqual("Quaternion(0.1, 0.22, 0.333, 0.4444)", q.ToString());
}
示例5: set
public void set(string key, Quaternion value)
{
debuggers [key] = value.ToString();
}
示例6: TestMemberFn_ToString
public void TestMemberFn_ToString ()
{
Quaternion a = new Quaternion(42, -17, 13, 44);
String result = a.ToString();
String expected = "{I:42 J:-17 K:13 U:44}";
Assert.That(result, Is.EqualTo(expected));
}
示例7: drive
public Vector3 drive(Quaternion p_current, Quaternion p_goal, float p_dt)
{
// To get quaternion "delta", rotate by the inverse of current
// to get to the origin, then multiply by goal rotation to get "what's left"
// The resulting quaternion is the "delta".
Quaternion error = p_goal * Quaternion.Inverse(p_current);
// Separate angle and axis, so we can feed the axis-wise
// errors to the PIDs.
Quaternion ri=Quaternion.identity; ri.w*=-1.0f;
// If quaternion is not a rotation
if (error == Quaternion.identity || error == ri)
{
m_vec = drive(Vector3.zero, Time.deltaTime);
}
else
{
float a;
Vector3 dir;
//error.ToAngleAxis(out a, out dir);
angleAxis(error, out dir, out a);
for (int i = 0; i < m_P.Length; i++)
{
bool isnan = false;
if (float.IsNaN(dir[i]))
{
Debug.Log(" dir is NaN. x" + dir.x + " y" + dir.y + " z" + dir.z);
isnan = true;
}
if (float.IsNaN(a))
{
Debug.Log(" a is NaN. a" + a);isnan = true;
}
float ad = dir[i]*a;
if (float.IsNaN(dir[i] * a))
{
Debug.Log(" mul is NaN. " + ad);isnan = true;
}
if (isnan)
Debug.Log("Orig quat="+p_current.ToString()+" inverted="+Quaternion.Inverse(p_current).ToString()+" err="+error.ToString());
}
// Get torque
//m_vec = drive(a * dir, Time.deltaTime);
m_vec = drive(Mathf.Rad2Deg*a*dir, Time.deltaTime);
}
return m_vec; // Note, these are 3 PIDs
}
示例8: SpawnPlayer
public GameObject SpawnPlayer( Vector3 position, Quaternion rotation )
{
Debug.Log( "Spawning player at position " + position.ToString() + rotation.ToString() );
GameObject playerObject = ( GameObject )Instantiate( playerPrefab, position, rotation );
return playerObject;
}
示例9: Start
// Use this for initialization
void Start()
{
knotPositions = new Vector3[pointsNumber];
shapes = new List<ShapeClass>();
for (int i = 0; i < pointsNumber; i++ )
{
knotPositions[i] = GetPointPositionInSpline(new Vector3(), new Vector3(0, 1, 0), new Vector3(2, 3, 0), new Vector3(3, 3, 0), (float)i / (float)(pointsNumber - 1));
}
originalShape = new ShapeClass(new Vector3[]{new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), new Vector3(1, 0, 1), new Vector3(1, 0, -1)});
shapes.Add(originalShape);
//startQ = new Quaternion(0, 0, 1, 0);
startQ = Quaternion.Euler(0, 0, 0);
startMatrix = Matrix4x4.TRS(new Vector3(), startQ, new Vector3(1, 1, 1));
endQ = Quaternion.Euler(0, 0, -90);
//endQ = new Quaternion(0, 1, 0, 0);
endMatrix = Matrix4x4.TRS(new Vector3(3, 3, 0), endQ, new Vector3(1, 1, 1));
//endQ = QuaternionFromMatrix(endMatrix);
print("end Quaternion=" + endQ.ToString() + " start Quaternion=" + startQ.ToString());
print("startMatrix=" + startMatrix.ToString());
//calculate angle between quaternions
// float angle = (180 * Mathf.Acos(Quaternion.Dot(startQ, endQ))) / Mathf.PI;
float angle = Mathf.Acos(Quaternion.Dot(startQ, endQ) / (GetQuaternionLength(startQ) * GetQuaternionLength(endQ)));
//print("Angle=" + angle.ToString());
endShape = new ShapeClass();
endShape.CopyFrom(originalShape);
endShape.MapsTo(endMatrix);
//calculate other shapes
for (int i = 1; i < pointsNumber-1; i++ )
{
//Quaternion middleQ = Quaternion.Lerp(startQ, endQ, (float)i * 100 / (float)(pointsNumber - 1));
Quaternion middleQ = GetInterpolatedQuaternion(startQ, endQ, angle, (float)i / (float)(pointsNumber - 1));
print(middleQ.ToString() + " " + ((float)i / (float)(pointsNumber - 1)).ToString());
Matrix4x4 middleMatrix = Matrix4x4.TRS(knotPositions[i], middleQ, new Vector3(1, 1, 1));
ShapeClass middleShape = new ShapeClass();
middleShape.CopyFrom(originalShape);
middleShape.MapsTo(middleMatrix);
shapes.Add(middleShape);
}
shapes.Add(endShape);
}
示例10: QuaternionToStringTest
public void QuaternionToStringTest()
{
Quaternion target = new Quaternion(-1.0f, 2.2f, 3.3f, -4.4f);
string expected = "{X:-1 Y:2.2 Z:3.3 W:-4.4}";
string actual;
actual = target.ToString();
Assert.AreEqual(expected, actual, "Quaternion.ToString did not return the expected value.");
}
示例11: Add
public static WWWForm Add(this WWWForm form, string key, Quaternion value)
{
form.AddField(key, value.ToString());
return form;
}
示例12: RotateBy
void RotateBy(float angles, Vector3 axis, float f)
{
Quaternion targetX = new Quaternion ();
//Something like this?
float upAndDownAngle = (angles * 0.0174533f) * 0.5f;
//ToOnGui ("upAngle", upAndDownAngle.ToString ());
float sinUDAngle = Mathf.Sin (upAndDownAngle);
Vector3 n = axis;
targetX.w = Mathf.Cos (upAndDownAngle);
targetX.x = n.x * sinUDAngle;
targetX.y = n.y * sinUDAngle;
targetX.z = n.z * sinUDAngle;
targetX = targetX * transform.rotation;
ToOnGui ("angleX:", targetX.ToString ());
transform.rotation = Quaternion.Slerp (transform.rotation, targetX, f);
}