Trigonometric functions.
Trigonometric calculation functions.
The CSS specification now provides for many calculation functions, including trigonometric calculations. These are interesting for calculating the parameters of a transformation (rotation, scaling, etc.).
Typical trigonometric functions: cos() - sin() - tan()
Inverse trigonometric functions: acos() - asin() - atan() - atan2().
It may also be useful to refer to the page on the CSS angle units.
These features can be used with:
The sin(), cos(), and tan() functions can be used with all the properties that are waiting
a unitless numerical value.
The asin(), acos(), atan(), and atan2() functions can be used with all
properties that expect an angular value.
Syntax of trigonometric calculation functions.
- <propriété>: sin(30deg); a
Calculate the sine of a. The valueamust be followed by a unit of angle.
The result is a unitless value, between-1and1.Some remarkable values:
sin(0)is0
sin(30deg)is0.5
sin(90deg)is1
- <propriété>: cos(30deg); a
Calculate the cosine of a. As with the previous function, the valueamust be followed by a unit of angle.
The result is a unitless value, between-1and1.Remarkable values :
cos(0)is1
cos(60deg)is0.5
cos(90deg)is0
- <propriété>: tan(45deg);
Calculate the tangent of a. As with the previous functions, the valueamust be followed by a unit of angle. The result is a unitless value, between-infinityand+infinity.Remarkable values:
tan(0)is0
tan(45deg)is1
tan(90deg)isinfinity
- <propriété>: asin(0.253); n
Calculates the arc sine of n, which means thatasin()finds the angle from the value of its sine, i.e. performs the inverse calculation ofsin(). Thevalue nmust be a unitless number, between-1and1.
Ifnis less than-1or greater than1, the result will beNaN(Not a Number).The angle calculated by the function is expressed in radians and is between
-1.5708radand1.5708rad, i.e., in degrees:-90degand90deg. - <propriété>: acos(0.124); n
The function acos(n)calculates the cosine arc ofn:acos()finds the angle from the value of its cosine, i.e. performs the inverse calculation ofcos(). Thevalue nmust be a unitless number, between-1and1.The calculated angle is expressed in radians and is in the range between
0radand3.14159rad, which corresponds in degrees to the range from0to180deg. - <propriété>: atan(2.212); n
atan(n)calculates the tangent arc ofn, i.e. finds the angle from the value of its tangent:atan()performs the reverse calculation oftan().
nmust be a number without units.The result is expressed in radians, and is in the range of
-1.5708radto+1.5708rador in degrees, from-90degto+90deg. - <propriété>: atan2(125px, 150px); y x
Calculates the angle between the x-axis and a point at the xandycoordinates.
xandycan be unitless numbers, percentages, or numbers followed by a dimension unit. These different possibilities cannot be mixed: the two values must be expressed in the same unit.The result is expressed in radians, and is in the range of
-3.14159radto+3.14159rad, or in degrees, from-180degto+180deg.The calculation performed by
atan2(y,x)is equivalent toatan(y/x)but the results of these two expressions can However, be different whenxand/oryhave negative values or whenxis0.xyatan(y/x)atan2(y,x)110,785rad
(45deg)0,785rad
(45deg)1-1-0,785rad
(-45deg)-0,785rad
(-45deg)-11-0,785rad
(-45deg)2,35rad
(135deg)-1-10,785rad
(45deg)-2,35rad
(-135deg)01Error1,57rad
(90deg)
Simulator.
To maintain type compatibility, the trigonometric functions sin(), cos(), and tan() are used
with the scale property, while inverse trigonometric functions, which return an angle, are used with the rotates property.
The predefined value pi (180 degrees) is also present, as an example. Notice that cos(pi) returns -1.
When scaled this value causes the element to flip.
scale: 1
rotate: 0deg
Browser compatibility and support.
Trigonometric calculation functions are now well handled by all current browsers.
cos() (cosine of an angle).sin() (sine of an angle).tan() (tangent of an angle).acos() (arc cosine of a value).asin() (arc sine of a value).atan() (arc tangent of a value).atan2() (arctangent from two values).cos()function
sin()function
tan()function
acos()function
asin()function
atan()function
atan2()function
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Chrome

Edge

Safari

Opéra

Firefox

Chrome pour Androïd

Safari sur IOS

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini
History of trigonometric functions.
-
CSS Values and Units Module Level 4
Trigonometric calculation functions are introduced in this level 4 of the specification.August 14, 2018Working Draft.
See also: Other calculation functions.
The calculation functions available in CSS are more and more numerous. They cover common mathematical and trigonometric calculations. For a more detailed description of these functions, you can refer to the W3C specification CSS Values and Units Module.
Properties:

Functions:


calc-size() allows calculations on the intrinsic dimension of an element (defined by the content).









Values:
e (the basis of natural logarithms), which is approximately 2.7182818284590452354.pi (about 3.1415926535897932).


