ab变换的那个t四元数。怎么求t呢  t * a = b 利用这个公式。四元数和矩阵的运算类似

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(TestOula))]
public class TestOulaEditor : Editor
{
public Quaternion a;
public Quaternion b;

public TestOula self
{
get
{
return target as TestOula;
}
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if(GUILayout.Button("记录a四元数"))
{
a = self.transform.localRotation;
}

if(GUILayout.Button("计算变换四元素得到初始位置"))
{
var b = self.transform.localRotation;
var t = b * Quaternion.Inverse(a);
var reverseT = Quaternion.Inverse(t);
self.transform.localRotation = reverseT * b; //
}

if (GUILayout.Button("记录b四元数"))
{
b = self.transform.localRotation;
}

if(GUILayout.Button("从a到b"))
{
var t = b * Quaternion.Inverse(a);
var reverseT = Quaternion.Inverse(t);
self.transform.localRotation = t * a;
}

if (GUILayout.Button("从b到a"))
{
var t = b * Quaternion.Inverse(a);
var reverseT = Quaternion.Inverse(t);
self.transform.localRotation = reverseT * b;
}

}
}

public class TestOula : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}
}

#### 最新留言

[***.36.149.97]2022年07月27日 00时49分41秒