일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 픽셀
- jQuery
- className
- javascript
- classList
- PYTHON
- 자주 사용하는 Quaternion 함수
- Event
- 독립변수
- wsl
- 연습
- 종속변수
- 코딩
- 도트
- 탑다운
- Lerp
- topdown
- intervals
- 웹스크래핑
- Unity
- euler
- getItem
- click
- 2D
- 도린이
- vsCode
- setItem
- addEventListener
- Quaternion
- 회전
Archives
- Today
- Total
쫑가 과정
두 회전 사이의 각 구하기 / Quaternion.Angle 본문
2. Quaternion.Angle
https://docs.unity3d.com/ScriptReference/Quaternion.Angle.html
public static float Angle(Quaternion a, Quaternion b);
a 와 b 두 회전 사이의 각도(degrees)를 도(angle) 단위로 반환한다.
예를 들어 세 번째 게임 오브젝트(C) 주위를 움직이는 두 개의 게임 오브젝트(A 및 B)를 생각해보자.
C에서 A로, C에서 B로의 선은 시간이 지남에 따라 변할 수 있는 삼각형을 만든다.
결과적으로 CA와 CB 사이의 각도는 Quaternion.Angle이 제공하는 값이다.
예)
using UnityEngine;
using System.Collections;
// Calculates the angle (degrees) between
// the rotation of this transform and target.
public class ExampleClass : MonoBehaviour
{
public Transform target;
void Update()
{
float angle = Quaternion.Angle(transform.rotation, target.rotation);
Debug.Log(angle);
}
}
쉽게 2D로 보자! 하얀 cube가 target이다.
1. angle = 90f
transform.rotation = Quaternion.Euler(new Vector(0,0,90f));
target.transform.rotation = Quaternion.Euler(new Vector(0,0,0));
2. angle = 60f (근사값으로 나옴)
transform.rotation = Quaternion.Euler(new Vector(0,0,90f));
target.transform.rotation = Quaternion.Euler(new Vector(0,0,30f));
3. angle = 120
transform.rotation = Quaternion.Euler(new Vector(0,0,120f));
target.transform.rotation = Quaternion.Euler(new Vector(0,0,0));
'Unity > 이론' 카테고리의 다른 글
축방향을 원하는 축방향으로 회전하기 / Quaternion.FromToRotation (0) | 2022.01.16 |
---|---|
두 각(Quaternion) 사이를 부드럽게 이어준다 / Quaternion.Slerp (0) | 2022.01.14 |
(Euler) 각을 (Quaternion) 값으로 바꾸기 / Quaternion.Euler (0) | 2022.01.13 |
타겟 방향 바라보기 함수 / Quaternion.LookRotation (0) | 2022.01.12 |
벡터 연산 이해하기 (0) | 2022.01.07 |
유니티3D 회전 이해 (0) | 2022.01.06 |
객체 지향 프로그래밍의 캡슐화 (0) | 2021.12.28 |
객체 지향 프로그래밍의 상속과 다형성 (0) | 2021.12.28 |
Comments