Was mache ich falsch in JavaScript?
Ich will die Rotation einen 2D-Versors berechnen und dafür, will ich erstmal den Realteil ausrechnen.
Mein Problem ist: Es rechnet einfach nicht.
Was mache ich falsch?:
window.addEventListener('keydown', (event) => {
if (event.keycode === '13') {
return
};
function calculate (calculate)
}
)
function calculate (calculate) {
let z_rotaited = document.getElementById('RotatedComplexversorZ');
let Rez = document.getElementById('Re(z)');
let Imz = document.getElementById('Im(z)');
let Rotationangle = document.getElementById('Rotationangleindegree');
let result = Math.sqrt(Rez ** 2 + Imz ** 2) * Math.cos(Rotationangle + Math.atan2(Rez, Imz) * 180 / Math.PI);
z_rotaited = result;
}
function calcAngleDegrees(containerRez, containerImz) {
return Math.atan2(containerRez, containerImz) * 180 / Math.PI;
}
(Wenn ich Enter drücke, soll die eine Funktion laufen, welche das rotierte z ausrechnet.
Die Funktion (mathematich gesehen) lautet:
z_{rotiert} = sqrt(Re(z)² + Im(z)²) * (phi + cos(arctan2(Re(z), Im(z))) i * sin(phi + arctan2(Re(z), Im(z))))
z = 2D-Versor
phi = der dazu adierte Winkel
Die Seite sieht so aus:
