Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to linear interpolate (lerp) between angles?

Author
Message
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 22nd Jan 2015 10:33
Hi,

does anyone know how to linear interpolate (lerp) between two angles in degrees (Tier 1)?

It needs to work even in those special cases:

LerpAngle( 90, 320 ) -> interpolate from 90 to 320 (-40), going left (not up from 90 to 320!)

LerpAngle( 330, 45 ) -> interpolate from 330 to 45, going right (not down from 330 to 45!)

It has to interpolate in the correct direction!

Here are some helper functions that I found:



Play Super Footie Online: SuperFootie.com

Development News: Forum Thread
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Jan 2015 11:16
First:

newAngle# = Lerp(90, -40, 0.5)

The last value is how far you are through the interpolation (i.e half way in this example)

Then:

newAngle# = WrapAngle(newAngle#)

Quidquid latine dictum sit, altum sonatur
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 22nd Jan 2015 17:14
If you want something automated, keep in mind the tweening functions.

Using AppGameKit v2 T1 + T2!
Systems: Primary: Mac OS X 10.10
Secondary: Windows 7
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 25th Jan 2015 12:17 Edited at: 25th Jan 2015 12:17
Quote: "
newAngle# = Lerp(90, -40, 0.5)
newAngle# = WrapAngle(newAngle#)"


Thanks for the help, I got it now.
Was easier than I thought

Quote: "If you want something automated, keep in mind the tweening functions."


I'm using AppGameKit V1 so no built-in tweening for me...

Play Super Footie Online: SuperFootie.com

Development News: Forum Thread

Login to post a reply

Server time is: 2024-05-05 00:27:54
Your offset time is: 2024-05-05 00:27:54