Cos() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns the cosine of a number. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Cos( num_expr ) 

num_expr is a numeric expression representing an angle in radians.

Return Value

Float

Description

The Cos() function returns the cosine of the numeric num_expr value, which represents an angle in radians. The result returned from Cos() is between one (1) and negative one (-1).

To convert a degree value to radians, multiply that value by DEG_2_RAD. To convert a radian value into degrees, multiply that value by RAD_2_DEG.

Note: Your program must Include "MAPBASIC.DEF" to reference DEG_2_RAD or RAD_2_DEG.

Example

Include "MAPBASIC.DEF"
Dim x, y As Float 
x = 60 * DEG_2_RAD 
y = Cos(x)

' y will now be equal to 0.5
' since the cosine of 60 degrees is 0.5 

See Also:

Acos() function, Asin() function, Atn() function, Sin() function, Tan() function