sin in javascript
Math.sin(Math.PI / 2);//it uses radians, pi/2 = 90 degrees, output:1
//make a function
const DegToRad = num => {return num * Math.PI / 180;};
Math.sin(DegToRad(90));//now its easy to read, output still 1
sin in javascript
Math.sin(Math.PI / 2);//it uses radians, pi/2 = 90 degrees, output:1
//make a function
const DegToRad = num => {return num * Math.PI / 180;};
Math.sin(DegToRad(90));//now its easy to read, output still 1
cos in javascript
import java.lang.*;
class MathDemo {
public static void main(String[] args) {
// get two double numbers
double x = 45.0;
double y = 180.0;
// convert them to radians
x = Math.toRadians(x);
y = Math.toRadians(y);
// print their cosine
System.out.println("Math.cos(" + x + ")=" + Math.cos(x));
System.out.println("Math.cos(" + y + ")=" + Math.cos(y));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us