I'm trying to interpolate angles in Expression 2 , as such:
local IAng_ = mix( Begin, End, 0.0-1.0 )
mix( v/a, v/a, n ) is a linear-interpolation function that is (probably) most easily described as:
function angle mix( Begin:angle, End:angle, Amount:number ){
return Begin * Amount + End * (1 - Amount)
}
Problem is: The 3D angle range is -180 to 180, which is causing some glitching. (According to my friend it has to do with Gimbal lock .
I've tried a couple of things, which haven't worked due to the nature of the angles in Source Engine:
function angle angle:to360(){
local Absolute = ang( abs( This:pitch() ), abs( This:yaw() ), abs( This:roll() ) )
local Pitch = This:pitch() < 0 ? Absolute:pitch() + 180 : Absolute:pitch()
local Yaw = This:yaw() < 0 ? Absolute:yaw() + 180 : Absolute:yaw()
local Roll = This:roll() < 0 ? Absolute:roll() + 180 : Absolute:roll()
return ang( Pitch, Yaw, Roll )
}
Or adding 180 to the angles.
TL;DR Interpolation of 3D angles facing the Gimbal lock problem (angle range -180 to 180), best solution would be to have a function that converts to 0 - 360 range and back to -180 - 180.
我最终使用quat( angle )
函数将角度转换为四元数,然后使用了内置的slerp(球面线性插值)函数,如下所示:
local Ang = slerp( quat( Angle1 ), quat( Angle2 ), Interp ):toAngle()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.