Pivot 기준으로 회전시키기 (Rotation about a Pivot)

in #kr5 years ago (edited)

public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 euler)
{
        return (Quaternion.Euler(euler) * (point - pivot)) + pivot;
}

회전의 기준이 오브젝트 중앙이라면 간단하게 회전시킬 수 있지만,
기준이 중앙에서 벗어난다면 회전 시 위치 이동과 회전을 동시에 해줘야
오브젝트가 회전하는 것처럼 보입니다.

point : 오브젝트의 현재 위치
pivot : 회전의 기준이 되는 위치
euler : x, y, z 축 회전각(Degree)

nimiq.png

Sort:  

Congratulations @pangcola! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 70 posts. Your next target is to reach 80 posts.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 61830.32
ETH 2914.09
USDT 1.00
SBD 3.62