상세 컨텐츠

본문 제목

Lerp와 LerpUnclamped는 뭐가 다른가? (difference of Lerp and unclamped lerp)

Computer Science/Unity

by 2021. 8. 16. 11:43

본문

반응형

프로젝트를 하며 자연스러운 카메라 이동을 구현하면서 Lerp와 LerpUnclamped의 차이에 관심을 갖게 되었는데요?

( 물론 Dotween을 사용하면 쉽겠지만, 특정 물체를 쫓아가는 단순한 움직임이기 때문에 굳히 사용하여 부하를 늘릴 필요는 없을 것 같았어요. )

 

평소에는 un clamped라는게 있구나, 하고 넘겼는데 이제서야 관심을 갖고 보게 되는군요.

 

https://www.reddit.com/r/Unity3D/comments/6kqy86/vector3_lerp_vs_lerpunclamped/

 

Vector3: Lerp vs LerpUnclamped

um... After reading the documents(which is essentially identical) I still don't understand what's the difference. Can anyone give me some insights?

www.reddit.com

당연히 레딧에서 질문이 있었죠!

답변은 간단 명쾌했습니다.

 

Unclamped lerps are allowed to go beyond the provided inputs if t is less than zero or greater than one. Normal lerps restrict the result so that it cannot be smaller than the smaller input or larger than the larger input.

Unclamped lerp는 lerp와 달리 t값(보간 정도 조정 상수)에 대한 제약이 없어 0 밑으로도, 1위로도 가능하다.

 

Mathf.LerpUnclamped(1.0, 2.0, 1.5) == 2.5
Mathf.Lerp (1.0, 2.0, 1.5) == 2.0

위 코드를 보면 일반적인 Lerp는 1보다 높은 t 값을 주더라도, 최대 허용값이 1이므로 b(두 번째 매개변수)의 값을 넘지 못합니다.

하지만 LerpUnclamped는 넘어가서 2.5라는 결과를 도출하는 군요.

반응형

관련글 더보기