Previous: , Up: Math   [Contents][Index]


4.2.6 Miscellaneous

(use-modules (sly math))

A grab bag of commonly used math functions and constants.

Scheme Variable: pi

An approximation of \pi, the ratio of a circle’s circumference to its diameter.

Scheme Variable: 2pi

2\pi

Scheme Variable: pi/2

\pi/2

Scheme Procedure: degrees->radians angle

Convert angle from degrees to radians.

Scheme Procedure: radians->degrees angle

Convert angle from radians to degrees.

Scheme Procedure: sin-degrees angle

Return the sine of angle, where angle is measured in degrees.

Scheme Procedure: cos-degrees angle

Return the cosine of angle, where angle is measured in degrees.

Scheme Procedure: tan-degrees angle

Return the tangent of angle, where angle is measured in degrees.

Scheme Procedure: atan-degrees y x

Return the arctangent of y and x, where y and x are measured in degrees.

Scheme Procedure: cotan z

Return the cotangent of z.

Scheme Procedure: clamp min max x

Restrict x to the range [min, max], assuming that min is actually less than max.

Scheme Procedure: linear-scale min max a b n

Map n in the range [min, max] to the range [a, b].

Scheme Procedure: half x

Return x / 2.

Scheme Procedure: square x

Return x^2.

Scheme Procedure: make-lerp + *

Return a new procedure that accepts three arguments: start, end, and alpha. The returned procedure uses the procedures + and * to linearly interpolate a value between start and end. alpha should always be in the range [0, 1].

Scheme Procedure: lerp start end alpha

Return the linear interpolation between the numbers start and end with scalar factor alpha.

Scheme Procedure: modulo* x y

Return the remainder of x / y. Works like regular modulo, except that x and y may be rational numbers or inexact numbers.


Previous: , Up: Math   [Contents][Index]