util.math.tan

Shared

Returns the tangent of an angle given in radians


Syntax

local result = util.math.tan(
    angle
)

Parameters

TypeNameDescription
floatangleAngle in radians

Returns

TypeNameDescription
floatresultTangent of angle

Examples

Tangent of 0
local result = util.math.tan(0)

core.engine.print("info", result) -- 0.0
Tangent of 45 degrees is 1
local result = util.math.tan(util.math.rad(45))

core.engine.print("info", result) -- 1.0
Tangent of a negative angle
local result = util.math.tan(util.math.rad(-45))

core.engine.print("info", result) -- -1.0
Calculate slope from an angle
local angle_deg = 30
local slope = util.math.tan(util.math.rad(angle_deg))

core.engine.print("info", slope) -- 0.57735
Compute height from distance and elevation angle
local distance = 100
local elevation_deg = 30
local height = distance*util.math.tan(util.math.rad(elevation_deg))

core.engine.print("info", height) -- 57.735
Verify tan equals sin over cos
local angle = util.math.rad(60)
local result = util.math.sin(angle)/util.math.cos(angle)

core.engine.print("info", result, util.math.tan(angle)) -- 1.7320  1.7320

On this page