acos

angle-modecljs

asin

atan

atan2

cos

degrees

radians

sin

tan

acos

Arguments
[n]
Docstring

The inverse of cos, returns the arc cosine of a value. This function expects the values in the range of -1 to 1 and values are returned in the range 0 to Math/PI (3.1415927).

Works only inside sketch functions?
No
Original Processing method
acos()
Original p5js method
acos()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/acos 0) = " (q/acos 0)) 10 20)
(q/text (str "(q/acos 1) = " (q/acos 1)) 10 40)
try example

angle-modecljs

Arguments
[mode]
Docstring

Sets the current mode of p5 to given mode. Options are: * :radians (default) * :degrees

Works only inside sketch functions?
Yes
Original Processing method
None.
Original p5js method
angleMode()
Example
clojurescript specific
  • ; draw a red square for reference
    (q/fill 255 0 0)
    (q/rect 0 0 100 100)
    ; rotation will be in degrees (instead of the default radians)
    (q/angle-mode :degrees)
    (q/rotate 45)
    ; draw a green square after the rotation of 45 degrees
    (q/fill 0 255 0)
    (q/rect 0 0 100 100)
    try example

asin

Arguments
[n]
Docstring

The inverse of sin, returns the arc sine of a value. This function expects the values in the range of -1 to 1 and values are returned in the range -PI/2 to PI/2.

Works only inside sketch functions?
No
Original Processing method
asin()
Original p5js method
asin()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/asin 0) = " (q/asin 0)) 10 20)
(q/text (str "(q/asin 1) = " (q/asin 1)) 10 40)
try example

atan

Arguments
[n]
Docstring

The inverse of tan, returns the arc tangent of a value. This function expects the values in the range of -Infinity to Infinity (exclusive) and values are returned in the range -PI/2 to PI/2.

Works only inside sketch functions?
No
Original Processing method
atan()
Original p5js method
atan()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/atan 0) = " (q/atan 0)) 10 20)
(q/text (str "(q/atan 1) = " (q/atan 1)) 10 40)
try example

atan2

Arguments
[y x]
Docstring

Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis. Values are returned as a float in the range from PI to -PI. The atan2 function is most often used for orienting geometry to the position of the cursor. Note: The y coordinate of the point is the first parameter and the x coordinate is the second due to the structure of calculating the tangent.

Works only inside sketch functions?
No
Original Processing method
atan2()
Original p5js method
atan2()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/atan2 2 1) = " (q/atan2 2 1)) 10 20)
(q/text (str "(q/atan2 1 2) = " (q/atan2 1 2)) 10 40)
try example

cos

Arguments
[angle]
Docstring

Calculates the cosine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to Math/PI*2). Values are returned in the range -1 to 1.

Works only inside sketch functions?
No
Original Processing method
cos()
Original p5js method
cos()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/cos 0) = " (q/cos 0)) 10 20)
(q/text (str "(q/cos q/HALF-PI) = " (q/cos q/HALF-PI)) 10 40)
try example

degrees

Arguments
[radians]
Docstring

Converts a radians measurement to its corresponding value in degrees. Radians and degrees are two ways of measuring the same thing. There are 360 degrees in a circle and 2*PI radians in a circle. For example, 90° = PI/2 = 1.5707964. All trigonometric methods in Processing require their parameters to be specified in radians.

Works only inside sketch functions?
No
Original Processing method
degrees()
Original p5js method
None.
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/degrees 0) = " (q/degrees 0)) 10 20)
(q/text (str "(q/degrees q/HALF-PI) = " (q/degrees q/HALF-PI)) 10 40)
try example

radians

Arguments
[degrees]
Docstring

Converts a degrees measurement to its corresponding value in radians. Radians and degrees are two ways of measuring the same thing. There are 360 degrees in a circle and 2*PI radians in a circle. For example, 90° = PI/2 = 1.5707964. All trigonometric methods require their parameters to be specified in radians.

Works only inside sketch functions?
No
Original Processing method
radians()
Original p5js method
radians()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/radians 0) = " (q/radians 0)) 10 20)
(q/text (str "(q/radians 90) = " (q/radians 90)) 10 40)
try example

sin

Arguments
[angle]
Docstring

Calculates the sine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to 6.28). A float within the range -1 to 1 is returned.

Works only inside sketch functions?
No
Original Processing method
sin()
Original p5js method
sin()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/sin 0) = " (q/sin 0)) 10 20)
(q/text (str "(q/sin q/HALF-PI) = " (q/sin q/HALF-PI)) 10 40)
try example

tan

Arguments
[angle]
Docstring

Calculates the ratio of the sine and cosine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to PI*2). Values are returned in the range infinity to -infinity.

Works only inside sketch functions?
No
Original Processing method
tan()
Original p5js method
tan()
Example
(q/background 255)
(q/fill 0)
(q/text (str "(q/tan 0) = " (q/tan 0)) 10 20)
(q/text (str "(q/tan  q/QUARTER-PI) = " (q/tan q/QUARTER-PI)) 10 40)
try example