math.cos

From GMod Wiki

Jump to: navigation, search
Function
Syntax math.cos( Number )
Where is this used?
Description:
Returns the cosine of a number (in radians).
Returns: Number number
Part of Library: Math
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Math.cos]Math.cos [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionGets the cosine of 60 degrees (returned in radians).
Used onNewerShared.png
Code
local angle = math.cos(60)
OutputThe variable angle will be set to -0.95241298...
DescriptionGet the cosine of 60 degrees after having converted it to radians. This would be useful if you are using degrees in your code and want to get the cosine of an angle not expressed in radians.
Used onNewerShared.png
Code
local angle = math.cos( math.rad(60) )
OutputThe variable angle will be set to 0.5. This is the cosine of 60 NOT in radians.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox