0 Pluspunkte 0 Minuspunkte

Ich habe diese Zeile und möchte die Drehung in Grad statt Rad angeben. Wie mache ich das?

var rotationAngle = Math.PI / 4; // 45 Grad im Uhrzeigersinn
var rotationMatrix = createRotationMatrix(rotationAngle);

von  

2 Antworten

0 Pluspunkte 0 Minuspunkte

Mit

winkel = grad * (PI / 180)

In dem Fall also

var rotationAngle = 45 * (Math.PI / 180); // 45 Grad im Uhrzeigersinn
var rotationMatrix = createRotationMatrix(rotationAngle);

von (716 Punkte)  
0 Pluspunkte 0 Minuspunkte
function degrees_to_radians(degrees) {
  var pi = Math.PI;
  return degrees * (pi / 180);
}

var radians = degrees_to_radians(45);
von