Global/LerpAngle

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=LerpAngle |Parent=Global |Description= |Realm=Shared |IsClass=No }} ")
 
(Initial Creation)
Line 2: Line 2:
 
|Name=LerpAngle
 
|Name=LerpAngle
 
|Parent=Global
 
|Parent=Global
|Description=
+
|Description=Returns point between first and second angle using given fraction and linear interpolation
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=ratio
 +
|desc=Ratio of progress through values
 +
}}
 +
{{Arg
 +
|type=Angle
 +
|name=angleStart
 +
|desc=Angle to begin from
 +
}}
 +
{{Arg
 +
|type=Angle
 +
|name=angleEnd
 +
|desc=Angle to end at
 +
}}
 +
{{Ret
 +
|type=Angle
 +
|desc=angle
 +
}}
 +
{{Example
 +
|Description=Turns an entity 180 degrees uses lerp over ten seconds
 +
|Code=local startAngle = Angle(0, 0, 0)
 +
local endAngle = Angle(0, 180, 0)
 +
local ratio = 0
 +
 +
timer.Create("Turn", 0.1, 10, function()
 +
    ratio = ratio + 0.1
 +
    entity:SetAngle(Lerp(ratio, startAngle, endAngle))
 +
end)
 
}}
 
}}

Revision as of 16:07, 3 June 2013

 LerpAngle( )

Contents

Description

Returns point between first and second angle using given fraction and linear interpolation

Arguments

number ratio

Ratio of progress through values

Arguments

Angle angleStart

Angle to begin from

Arguments

Angle angleEnd

Angle to end at

Returns

Angle

angle

Examples

Example

Turns an entity 180 degrees uses lerp over ten seconds

local startAngle = Angle(0, 0, 0)
local endAngle = Angle(0, 180, 0)
local ratio = 0

timer.Create("Turn", 0.1, 10, function()
    ratio = ratio + 0.1
    entity:SetAngle(Lerp(ratio, startAngle, endAngle))
end)


Personal tools
Navigation