D K
D K

Reputation: 1

Angles in javascript

Why aren't angles in js like the angles we've learnt about? I'm trying to make spinner wheel in js, and noticed that using

    for(i<sides)  
    const angle = (360 / sides) * i;

isn't quite enough.

Why is that?

Later I found out that you have to do it like this

const sides = 3;
const angle = (i / sides) * (Math.PI * 2) - Math.PI / 2;                
const x = Math.cos(angle) * radius + startingX;

Upvotes: -4

Views: 63

Answers (1)

D K
D K

Reputation: 1

So i solved it like this:

const sides = 3;
const angle = (i / sides) * (Math.PI * 2) - 
Math.PI / 2;                
const x = Math.cos(angle) * radius + startingX;

Math.cos e sin use radians as params not °

Upvotes: -2

Related Questions