ScriptReference/Quaternion #720
Replies: 1 comment
-
Vector3 worldForward = rotation * Vector3.forward;
Quaternion diff = Quaternion.Inverse(A) * B; Here is a script that shows all possibilities to help you wrap your head around this concept: #if UNITY_EDITOR
using System;
using UnityEditor;
#endif
using UnityEngine;
public class QuaterionTest : MonoBehaviour
{
public Quaternion A = Quaternion.identity;
public Quaternion B = Quaternion.identity;
#if UNITY_EDITOR
[CustomEditor(typeof(QuaterionTest))]
public class QuaterionTestInspector : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
}
private void OnEnable() => SceneView.duringSceneGui += OnSceneGUI;
private void OnDisable() => SceneView.duringSceneGui -= OnSceneGUI;
private void OnSceneGUI(SceneView view)
{
var t = target as QuaterionTest;
Handles.DrawLine(t.transform.position, Vector3.zero);
var pos = t.transform.position;
Handles.Label(pos, "A");
Handles.DoPositionHandle(pos, t.transform.rotation * t.A);
pos += t.transform.right;
Handles.Label(pos, "B");
Handles.DoPositionHandle(pos, t.transform.rotation * t.B);
pos += t.transform.right;
Handles.Label(pos, "A * B");
Handles.DoPositionHandle(pos, t.transform.rotation * t.A * t.B);
pos += t.transform.right;
Handles.Label(pos, "inv(A) * B");
Handles.DoPositionHandle(pos, t.transform.rotation * Quaternion.Inverse(t.A) * t.B);
pos += t.transform.right;
Handles.Label(pos, "A * inv(B)");
Handles.DoPositionHandle(pos, t.transform.rotation * t.A * Quaternion.Inverse(t.B));
}
}
#endif
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
ScriptReference/Quaternion
https://docs.unity3d.com/ScriptReference/Quaternion.html
Beta Was this translation helpful? Give feedback.
All reactions