Try this
//This command will return a value that does not exceed the range of 0 to 360.
function WrapAngle( angle as float)
local iChunkOut as integer
local breakout as integer
iChunkOut = angle
iChunkOut = iChunkOut - mod( iChunkOut, 360 )
angle = angle - iChunkOut
breakout = 10000
while angle < 0.0 or angle >= 360.0
if angle < 0.0 then angle = angle + 360.0
if angle >= 360.0 then angle = angle - 360.0
dec breakout
if breakout = 0 then exit
endwhile
if breakout = 0 then angle = 0.0
endfunction angle
//This command will return an auto-interpolated angle based on a given speed.
function CurveAngle( destination as float, current as float, speed as float)
local diff as float
if speed < 1.0 then speed = 1.0
destination = WrapAngle( destination )
current = WrapAngle( current )
diff = destination - current
if diff <- 180.0 then diff = ( destination + 360.0 ) - current
if diff > 180.0 then diff = destination - ( current + 360.0 )
current = current + ( diff / speed )
current = WrapAngle( current )
endfunction current
//This command will return an auto-interpolated value based on a given speed.
function CurveValue( destination as float, current as float, speed as float)
local diff as float
if speed < 1.0 then speed = 1.0
diff = destination - current
current = current + ( diff / speed )
endfunction current
//This command will return a value that represents the new X position of a point in 3D space
// currentXValue -- current value to calculate the new value from.
// angleValue -- angle value in degrees 0 to 360
// stepValue -- specifies how far in the specified direction you would like to calculate
function CalculateNewXValue( currentXValue as float, angleValue as float, stepValue as float )
result# = currentXValue + ( sin( angleValue ) * stepValue )
endfunction result#
//This command will return a value that represents the new Y position of a point in 3D space
// currentXValue -- current value to calculate the new value from.
// angleValue -- angle value in degrees 0 to 360
// stepValue -- specifies how far in the specified direction you would like to calculate
function CalculateNewYValue( currentYValue as float, angleValue as float, stepValue as float )
result# = currentYValue - ( sin( angleValue ) * stepValue )
endfunction result#
//This command will return a value that represents the new Z position of a point in 3D space
// currentXValue -- current value to calculate the new value from.
// angleValue -- angle value in degrees 0 to 360
// stepValue -- specifies how far in the specified direction you would like to calculate
function CalculateNewZValue( currentZValue as float, angleValue as float, stepValue as float )
result# = currentZValue + ( cos( angleValue ) * stepValue )
endfunction result#
The coffee is lovely dark and deep,and I have code to write before I sleep.