21.06.2014 Views

GLSL Spec

GLSL Spec

GLSL Spec

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8 Built-in Functions<br />

8.1 Angle and Trigonometry Functions<br />

Function parameters specified as angle are assumed to be in units of radians. In no case will any of these<br />

functions result in a divide by zero error. If the divisor of a ratio is 0, then results will be undefined.<br />

These all operate component-wise. The description is per component.<br />

Syntax<br />

genType radians (genType degrees)<br />

Description<br />

Converts degrees to radians, i.e.,<br />

<br />

180 ⋅degrees<br />

genType degrees (genType radians)<br />

Converts radians to degrees, i.e.,<br />

180<br />

⋅radians<br />

genType sin (genType angle)<br />

The standard trigonometric sine function.<br />

genType cos (genType angle)<br />

The standard trigonometric cosine function.<br />

genType tan (genType angle)<br />

The standard trigonometric tangent.<br />

genType asin (genType x)<br />

genType acos (genType x)<br />

genType atan (genType y, genType x)<br />

genType atan (genType y_over_x)<br />

Arc sine. Returns an angle whose sine is x. The range<br />

of values returned by this function is<br />

[ − 2 , 2 ]<br />

Results are undefined if<br />

∣x∣1.<br />

Arc cosine. Returns an angle whose cosine is x. The<br />

range of values returned by this function is [0, π].<br />

Results are undefined if ∣x∣1.<br />

Arc tangent. Returns an angle whose tangent is y/x. The<br />

signs of x and y are used to determine what quadrant the<br />

angle is in. The range of values returned by this<br />

function is [−, ]. Results are undefined if x and<br />

y are both 0.<br />

Arc tangent. Returns an angle whose tangent is<br />

y_over_x. The range of values returned by this function<br />

is<br />

[ − 2 , 2 ]<br />

.<br />

115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!