본문 바로가기
Metaverse World Creator/Unity & C#

08.Quaternion : 회전값을 계산하는 유니티만의 표현?

by 캉캉. 2022. 5. 13.

4차원 행렬로 표현

https://docs.unity3d.com/2020.3/Documentation/ScriptReference/Quaternion.html

 

Unity - Scripting API: Quaternion

They are compact, don't suffer from gimbal lock and can easily be interpolated. Unity internally uses Quaternions to represent all rotations. They are based on complex numbers and are not easy to understand intuitively. You almost never access or modify in

docs.unity3d.com

우리가 알고있는 x,y,z 삼원체계와 다른것

public class QuaternionClass : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{

Debug.Log("Quaternion x = " + transform.rotation.x);

Debug.Log("Degree x = " + transform.eulerAngles.x);

}

// Update is called once per frame

void Update()

{

transform.rotation =

Quaternion.Lerp(transform.rotation,Quaternion.Euler(180,0,0),0.1f);

 

//현재 회전값에서 쿼터니언 회전값까지 회전시키는것

 

콘솔창에서 보면 쿼터니언 체계와 디그리 체계가 다른것을 알 수 있다.

디그리에서30도가 우리가 알고있는 30도 회전값이다.

LIST