Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
|
vektor [2024/10/15 07:24] |
vektor [2024/12/07 17:32] (aktuell) |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | [[todo]] | ||
| + | Punkte in einem 3 dimensionalen Raum (Koordinaten) werden in einer Zeile dargestellt, | ||
| + | |||
| + | https:// | ||
| + | |||
| + | < | ||
| + | KoordinateA = (1,2,3) | ||
| + | |||
| + | 1 | ||
| + | VektorB = 2 | ||
| + | 3 | ||
| + | </ | ||
| + | |||
| + | Verschiedene Arten und was man dadurch erhält. | ||
| + | |||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | =====Vektoren addieren===== | ||
| + | |||
| + | Vektoraddition und -subtraktion sind grundlegende Operationen, | ||
| + | |||
| + | * Jede Zeile miteinander addieren, das Ergebnis ist ein neuer Vektor. | ||
| + | * Man kann einen Vektor NICHT mit einem Skalar addieren (undefined). | ||
| + | |||
| + | < | ||
| + | 2 | ||
| + | VectorA = 3 | ||
| + | 4 | ||
| + | |||
| + | 3 | ||
| + | VectorB = 4 | ||
| + | 5 | ||
| + | | ||
| + | 2 | ||
| + | VectorC = 3 + 4 = 7 | ||
| + | 4 | ||
| + | </ | ||
| + | |||
| + | =====Vektoren multiplizieren===== | ||
| + | |||
| + | ====Skalarprodukt==== | ||
| + | |||
| + | Das Skalarprodukt (auch bekannt als Punktprodukt) wird verwendet, um den Winkel zwischen zwei Vektoren zu berechnen. Es ist auch nützlich, um die Geschwindigkeit eines Objekts in eine bestimmte Richtung zu bestimmen oder um zu überprüfen, | ||
| + | |||
| + | ====Kreuzprodukt==== | ||
| + | |||
| + | Das Kreuzprodukt (auch bekannt als Vektorprodukt) wird in der dreidimensionalen Geometrie verwendet, um einen neuen Vektor zu erzeugen, der senkrecht auf den beiden Ausgangsvektoren steht. Es ist nützlich für die Berechnung von Oberflächennormalen, | ||
| + | |||
| + | =====Vektorlänge und Normalisierung===== | ||
| + | |||
| + | Die Länge eines Vektors kann berechnet werden, indem die Wurzel der Summe der Quadrate seiner Komponenten genommen wird. Dies ist nützlich, um die Geschwindigkeit eines Objekts zu bestimmen oder um zu überprüfen, | ||
| + | ====Vektoren multiplizieren==== | ||
| + | |||
| + | * Multipliziert man einen Vektor und ein Skalar erhält man einen neuen Vektor - multipliziert man 2 Vektoren erhält man ein **Skalarprodukt** (normale Zahl). | ||
| + | * Multiplikation ändert nur die Länge, NICHT die Richtung! | ||
| + | |||
| + | < | ||
| + | 2 | ||
| + | VectorA = 3 | ||
| + | 4 | ||
| + | | ||
| + | 2 6 | ||
| + | VectorB = 3 * 3 = 9 | ||
| + | 4 12 | ||
| + | | ||
| + | 2 3 | ||
| + | VectorC = 3 * 4 = 2 * 3 + 3 * 4 + 4 * 5 = 38 | ||
| + | 4 5 | ||
| + | </ | ||
| + | |||
| + | * Multipliziert man 2 Vektoren und erhält 0 als Ergebnis, sind diese **orthogonal** (stehen im rechten Winkel aufeinander). | ||
| + | * Besonders wichtig in der 3D Programmierung ist das **Kreuzprodukt**, | ||
| + | |||
| + | =====Dot product 3D===== | ||
| + | |||
| + | Das Dot-Produkt (auch Skalarprodukt genannt) ist eine mathematische Operation, die auf zwei Vektoren angewendet wird und einen Skalar (eine Zahl) als Ergebnis liefert. Es wird häufig verwendet, um den Winkel zwischen zwei Vektoren zu berechnen oder um zu überprüfen, | ||
| + | |||
| + | Für zwei Vektoren | ||
| + | |||
| + | A = (a1, a2, a3) | ||
| + | B = (b1, b2, b3) | ||
| + | |||
| + | im 3D-Raum lautet die Formel für das Dot-Produkt: | ||
| + | |||
| + | A * B = a1 + b1 + a2 * b2 + a3 * b3 | ||
| + | |||
| + | Die Berechnung des Dot-Produkts erfolgt durch die Multiplikation der entsprechenden Komponenten der beiden Vektoren und das anschließende Addieren der Produkte. | ||
| + | |||
| + | Geometrische Bedeutung: | ||
| + | Das Dot-Produkt lässt sich auch in Bezug auf den Winkel PHI zwischen den beiden Vektoren ausdrücken: | ||
| + | |||
| + | A⋅B=∣A∣⋅∣B∣⋅cos(θ) | ||
| + | |||
| + | ∣A∣ ist die Länge von Vektor A. ∣B∣ ist die Länge von Vektor B. θ ist der Winkel zwischen den beiden Vektoren. | ||
| + | |||
| + | Das Dot-Produkt ist besonders nützlich, um zu bestimmen, ob zwei Vektoren in die gleiche Richtung zeigen: | ||
| + | |||
| + | * Wenn das Dot-Produkt positiv ist, ist der Winkel zwischen den Vektoren weniger als 90°. | ||
| + | * Wenn das Dot-Produkt null ist, sind die Vektoren orthogonal (rechtwinklig zueinander). | ||
| + | * Wenn das Dot-Produkt negativ ist, ist der Winkel zwischen den Vektoren größer als 90°. | ||
| + | |||
| + | Beispiel: | ||
| + | Nehmen wir die Vektoren A=(1,2,3) und B=(4, | ||
| + | |||
| + | Das Dot-Produkt ist: A⋅B=(1⋅4)+(2⋅−5)+(3⋅6)=4−10+18=12 | ||
| + | |||
| + | Das Ergebnis ist der Skalar 12. Dies bedeutet, dass die Vektoren in eine ähnliche Richtung zeigen. | ||
| + | |||
| + | {{vektor_definieren.png}} | ||
| + | =====Cross product===== | ||
| + | |||
| + | Das Kreuzprodukt zweier Vektoren im 3D-Raum ergibt einen Vektor, der senkrecht (orthogonal) auf beiden Eingangsvektoren steht. | ||
| + | |||
| + | |||
| + | Für zwei Vektoren | ||
| + | |||
| + | A = (a1, a2, a3) | ||
| + | B = (b1, b2, b3) | ||
| + | |||
| + | im 3D-Raum lautet die Formel für das Cross-Produkt: | ||
| + | |||
| + | < | ||
| + | | i, j, k | | ||
| + | A * B = | a1, a2, a3 | | ||
| + | | b1, b2, b3 | | ||
| + | </ | ||
| + | |||
| + | | ||
| + | Dabei sind i,j,k die Einheitsvektoren entlang der x-, y- und z-Achse. | ||
| + | |||
| + | Die Berechnung erfolgt durch die Determinante der Matrix, die die Komponenten der beiden Vektoren enthält. | ||
| + | |||
| + | < | ||
| + | A * B = ((a2 * b3 - a3 * b2), (a3 * b1 - a1 * b3), (a1 * b2 - a2 * b1)) | ||
| + | </ | ||
| + | |||
| + | Das Cross-Produkt ergibt einen Vektor, der senkrecht auf der Ebene steht, die durch die beiden Vektoren A und B aufgespannt wird. | ||
| + | Die Länge des resultierenden Vektors entspricht der Fläche des Parallelogramms, | ||
| + | |||
| + | |||
| + | {{kreuzprodukt.png}} | ||
| + | |||
| + | =====Lage von Geraden im Raum===== | ||
| + | |||
| + | (Stützvektor) Welche Koordinaten schneidet eine Gerade? | ||
| + | |||
| + | https:// | ||
| + | |||
| + | =====Gegenseitige Lage von Geraden im Raum===== | ||
| + | |||
| + | Berechnen ob sie | ||
| + | |||
| + | * Parallel | ||
| + | * gleich | ||
| + | * sich schneidend | ||
| + | * windschief | ||
| + | |||
| + | sind. | ||
| + | |||
| + | https:// | ||
| + | |||
| + | =====Normalformen und Projektion===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | =====Vektor Visualisierung===== | ||
| + | |||
| + | < | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | body { margin: 0; font-family: | ||
| + | canvas { display: block; } | ||
| + | .controls { | ||
| + | position: absolute; | ||
| + | top: 10px; | ||
| + | left: 10px; | ||
| + | z-index: 1; | ||
| + | background: rgba(255, 255, 255, 0.7); | ||
| + | padding: 15px; | ||
| + | width: 240px; | ||
| + | height: 90%; | ||
| + | overflow-y: auto; | ||
| + | } | ||
| + | .section { | ||
| + | margin-bottom: | ||
| + | } | ||
| + | .section h3 { | ||
| + | margin-top: 0; | ||
| + | } | ||
| + | .section input, .section button { | ||
| + | width: 100%; | ||
| + | margin-bottom: | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <div class=" | ||
| + | <!-- Vektor Eingabe --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <button onclick=" | ||
| + | </ | ||
| + | |||
| + | <!-- Vektor Operationen --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <button onclick=" | ||
| + | <button onclick=" | ||
| + | <button onclick=" | ||
| + | </ | ||
| + | |||
| + | <!-- Rotation der Szene --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | |||
| + | <!-- Kamera Position und Rotation --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <label for=" | ||
| + | <input type=" | ||
| + | |||
| + | <button onclick=" | ||
| + | <button onclick=" | ||
| + | </ | ||
| + | |||
| + | <!-- Ausgabe --> | ||
| + | <div class=" | ||
| + | <span id=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <script src=" | ||
| + | <script src=" | ||
| + | |||
| + | < | ||
| + | const scene = new THREE.Scene(); | ||
| + | const camera = new THREE.PerspectiveCamera(75, | ||
| + | const renderer = new THREE.WebGLRenderer(); | ||
| + | renderer.setSize(window.innerWidth, | ||
| + | document.body.appendChild(renderer.domElement); | ||
| + | |||
| + | const light = new THREE.AmbientLight(0x404040, | ||
| + | scene.add(light); | ||
| + | |||
| + | const directionalLight = new THREE.DirectionalLight(0xffffff, | ||
| + | directionalLight.position.set(5, | ||
| + | scene.add(directionalLight); | ||
| + | |||
| + | function zoomIn() { | ||
| + | if (camera.position.z > 1) { | ||
| + | camera.position.z -= 1; | ||
| + | renderer.render(scene, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function zoomOut() { | ||
| + | camera.position.z += 1; | ||
| + | renderer.render(scene, | ||
| + | } | ||
| + | |||
| + | let v1 = new THREE.Vector3(1, | ||
| + | let v2 = new THREE.Vector3(3, | ||
| + | |||
| + | let arrowV1, arrowV2, arrowResultant, | ||
| + | |||
| + | function createArrow(vector, | ||
| + | const arrowHelper = new THREE.ArrowHelper(vector.clone().normalize(), | ||
| + | scene.add(arrowHelper); | ||
| + | return arrowHelper; | ||
| + | } | ||
| + | |||
| + | function createAxisAndScale() { | ||
| + | var maxNum = 9999; | ||
| + | |||
| + | const xAxisGeometry = new THREE.BufferGeometry().setFromPoints([ | ||
| + | new THREE.Vector3(0, | ||
| + | new THREE.Vector3(maxNum, | ||
| + | ]); | ||
| + | const xAxisMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 }); | ||
| + | const xAxis = new THREE.Line(xAxisGeometry, | ||
| + | scene.add(xAxis); | ||
| + | |||
| + | const yAxisGeometry = new THREE.BufferGeometry().setFromPoints([ | ||
| + | new THREE.Vector3(0, | ||
| + | new THREE.Vector3(0, | ||
| + | ]); | ||
| + | const yAxisMaterial = new THREE.LineBasicMaterial({ color: 0x00ff00 }); | ||
| + | const yAxis = new THREE.Line(yAxisGeometry, | ||
| + | scene.add(yAxis); | ||
| + | |||
| + | const zAxisGeometry = new THREE.BufferGeometry().setFromPoints([ | ||
| + | new THREE.Vector3(0, | ||
| + | new THREE.Vector3(0, | ||
| + | ]); | ||
| + | const zAxisMaterial = new THREE.LineBasicMaterial({ color: 0x0000ff }); | ||
| + | const zAxis = new THREE.Line(zAxisGeometry, | ||
| + | scene.add(zAxis); | ||
| + | |||
| + | for (let i = 1; i <= maxNum; i++) { | ||
| + | const xMarker = new THREE.Mesh( | ||
| + | new THREE.SphereGeometry(0.1), | ||
| + | new THREE.MeshBasicMaterial({ color: 0xff0000 }) | ||
| + | ); | ||
| + | xMarker.position.set(i, | ||
| + | scene.add(xMarker); | ||
| + | |||
| + | const yMarker = new THREE.Mesh( | ||
| + | new THREE.SphereGeometry(0.1), | ||
| + | new THREE.MeshBasicMaterial({ color: 0x00ff00 }) | ||
| + | ); | ||
| + | yMarker.position.set(0, | ||
| + | scene.add(yMarker); | ||
| + | |||
| + | const zMarker = new THREE.Mesh( | ||
| + | new THREE.SphereGeometry(0.1), | ||
| + | new THREE.MeshBasicMaterial({ color: 0x0000ff }) | ||
| + | ); | ||
| + | zMarker.position.set(0, | ||
| + | scene.add(zMarker); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function updateVectors() { | ||
| + | v1.set( | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | ); | ||
| + | |||
| + | v2.set( | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | ); | ||
| + | |||
| + | scene.clear(); | ||
| + | |||
| + | createAxisAndScale(); | ||
| + | |||
| + | arrowV1 = createArrow(v1, | ||
| + | arrowV2 = createArrow(v2, | ||
| + | |||
| + | if (arrowResultant) scene.remove(arrowResultant); | ||
| + | if (arrowDifference) scene.remove(arrowDifference); | ||
| + | if (arrowCrossProduct) scene.remove(arrowCrossProduct); | ||
| + | |||
| + | displayVectorComponents(v1, | ||
| + | displayVectorComponents(v2, | ||
| + | |||
| + | renderer.render(scene, | ||
| + | } | ||
| + | |||
| + | function toggleResultant() { | ||
| + | if (arrowResultant) { | ||
| + | scene.remove(arrowResultant); | ||
| + | arrowResultant = null; | ||
| + | } else { | ||
| + | arrowResultant = createArrow(v1.clone().add(v2), | ||
| + | displayVectorComponents(v1.clone().add(v2), | ||
| + | renderer.render(scene, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function toggleDifference() { | ||
| + | if (arrowDifference) { | ||
| + | scene.remove(arrowDifference); | ||
| + | arrowDifference = null; | ||
| + | } else { | ||
| + | arrowDifference = createArrow(v1.clone().sub(v2), | ||
| + | displayVectorComponents(v1.clone().sub(v2), | ||
| + | renderer.render(scene, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function toggleCrossProduct() { | ||
| + | if (arrowCrossProduct) { | ||
| + | scene.remove(arrowCrossProduct); | ||
| + | arrowCrossProduct = null; | ||
| + | } else { | ||
| + | arrowCrossProduct = createArrow(v1.clone().cross(v2), | ||
| + | displayVectorComponents(v1.clone().cross(v2), | ||
| + | renderer.render(scene, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function displayVectorComponents(vector, | ||
| + | const output = document.getElementById(' | ||
| + | const outputText = `${label} - x: ${vector.x.toFixed(2)}, | ||
| + | output.textContent = outputText; | ||
| + | console.log(outputText); | ||
| + | } | ||
| + | |||
| + | /* | ||
| + | camera.position.x = document.getElementById(" | ||
| + | camera.position.y = document.getElementById(" | ||
| + | camera.position.z = document.getElementById(" | ||
| + | */ | ||
| + | |||
| + | function animate() { | ||
| + | requestAnimationFrame(animate); | ||
| + | |||
| + | scene.rotation.x = document.getElementById(' | ||
| + | scene.rotation.y = document.getElementById(' | ||
| + | scene.rotation.z = document.getElementById(' | ||
| + | |||
| + | renderer.render(scene, | ||
| + | } | ||
| + | |||
| + | function updateCamera() { | ||
| + | camera.position.set( | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | ); | ||
| + | |||
| + | camera.rotation.set( | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | parseFloat(document.getElementById(' | ||
| + | ); | ||
| + | |||
| + | renderer.render(scene, | ||
| + | } | ||
| + | |||
| + | window.addEventListener(' | ||
| + | renderer.setSize(window.innerWidth, | ||
| + | camera.aspect = window.innerWidth / window.innerHeight; | ||
| + | camera.updateProjectionMatrix(); | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | scene.rotation.x = this.value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | scene.rotation.y = this.value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | scene.rotation.z = this.value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | const value = parseFloat(this.value); | ||
| + | scene.rotation.x = value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | const value = parseFloat(this.value); | ||
| + | scene.rotation.y = value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | const value = parseFloat(this.value); | ||
| + | scene.rotation.z = value * Math.PI / 180; | ||
| + | document.getElementById(' | ||
| + | }); | ||
| + | |||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | animate(); | ||
| + | updateVectors(); | ||
| + | updateCamera(); | ||
| + | |||
| + | //for(var i = 0; i<5; i++) zoomOut(); | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | =====Links===== | ||
| + | |||
| + | Ganze Youtube Playlist https:// | ||
| + | |||
| + | Matritzen: http:// | ||
| + | |||
| + | Vektorrechnen https:// | ||