Trigonometry Conversion Operators: Difference between revisions

From GiderosMobile
No edit summary
m Text replacement - "<source" to "<syntaxhighlight"
Line 11: Line 11:
=== Examples ===
=== Examples ===
'''Simple degree to radian (^<) examples'''
'''Simple degree to radian (^<) examples'''
<source lang="lua">
<syntaxhighlight lang="lua">
r=^<d -- faster than r=math.rad(d)
r=^<d -- faster than r=math.rad(d)
radAngle=^<sprite:getRotation()
radAngle=^<sprite:getRotation()
Line 18: Line 18:


'''Simple radian to degree (^>) examples'''
'''Simple radian to degree (^>) examples'''
<source lang="lua">
<syntaxhighlight lang="lua">
d=^>r -- faster than d=math.deg(r)
d=^>r -- faster than d=math.deg(r)
sprite:setRotation(^>math.sin(0.5))
sprite:setRotation(^>math.sin(0.5))

Revision as of 13:31, 13 July 2023

Supported platforms:
Available since: Gideros 2017.10

Description

Operators to convert from one type of measurement to another.

^< deg   Convert 'deg' into radians
^> rad   Convert 'rad' into degrees

Examples

Simple degree to radian (^<) examples <syntaxhighlight lang="lua"> r=^<d -- faster than r=math.rad(d) radAngle=^<sprite:getRotation() pi=^<180 -- pi is 3.142 in radians or 180 in degrees </source>

Simple radian to degree (^>) examples <syntaxhighlight lang="lua"> d=^>r -- faster than d=math.deg(r) sprite:setRotation(^>math.sin(0.5)) </source>