p5.js | acos() function
The acos() function in p5.js is used to calculate the arc cosine value. The domain of this function is -1 to +1 and the range is 0 to 3.14.
Syntax:
acos(c)
Parameters: This function accepts single parameter c which stores the value in between -1 to 1.
Below programs illustrate the acos() function in p5.js:
Example 1: This example uses acos() function to calculate arc cosine value.
function setup() { // Create Canvas of size 380*80 createCanvas(380, 80); } function draw() { // Set the background color background(220); // Set the angle in radian let angle = PI; // Compute value of cos() let c = cos(angle); // Compute value of acos() // It returns the value of PI let ac = acos(c); // Set the font size textSize(16); // Set the font color fill(color('red')); // Display result text("Value of acos is : " + ac, 50, 30); } |
Output:

Example 2: This example uses acos() function to calculate arc cosine value.
function setup() { // Create Canvas of given size createCanvas(380, 80); } function draw() { // Set the background color background(220); let c = 0.5; // Use acos() function to calculate // arc cosine value let ac = acos(c); // Set font size textSize(16); // Set font color fill(color('red')); // Display result text("Value of acos is : " + ac, 50, 30); } |
Output:

Reference: https://p5js.org/reference/#/p5/acos
Recommended Posts:
- PHP | acos( ) Function
- Math.acos( ) In JavaScript
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- PHP | exp() Function
- CSS | url() Function
- D3.js | d3.lab() Function
- PHP | dir() Function
- PHP | pi( ) Function
- D3.js | d3.map.set() Function
- PHP | end() Function
- D3.js | d3.hcl() Function
- D3.js | d3.min() function
- p5.js | nfc() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

