0
Ich muss eine Rotationsfunktion erstellen, die verwendet wird, um Elemente zu drehen, es funktioniert fast abgesehen von dem Versuch, -Sin zu tun. Es scheint keine Funktion zu geben, die dies erlaubt.Erstellen von Rotationsmatrix
Matrix.createRotation = function (rotation) {
return new Matrix(Math.cos(rotation), Math.sin(rotation), 0,
Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
};
Was ist mit etwas wie '(-1) * Math.sin (Rotation)'? Sollte das nicht funktionieren? Wie in der Funktion sollte so sein, 'zurück neue Matrix (Math.cos (Rotation), (-1) * Math.sin (Rotation), 0, Math.sin (Rotation), Math.cos (Rotation), 0 , 0, 0, 1); ' – TheNavigat
Ja, du hast Recht, es funktioniert. – Quad117
In Ihrem Beispiel negieren Sie nicht einmal das Ergebnis von 'Math.sin (Rotation)'. Es sollte '-Math.sin (Rotation)' sein - es ist schneller als Multiplikation mit -1. Wie erwartest du '-sin (Rotation)' wenn du das Ergebnis von 'sin (rotation) nicht negierst? – plasmacel