diff --git a/vector-calculation/assets/Screenshot_Calc.png b/vector-calculation/assets/Screenshot_Calc.png new file mode 100644 index 00000000..68ec6bb8 Binary files /dev/null and b/vector-calculation/assets/Screenshot_Calc.png differ diff --git a/vector-calculation/index.html b/vector-calculation/index.html new file mode 100644 index 00000000..7d94c9a4 --- /dev/null +++ b/vector-calculation/index.html @@ -0,0 +1,45 @@ + + + + + + + 3D Vector Operations Calculator + + +
+

3D Vector Operations Calculator

+ +
+
+

Vector A

+ + + +
+ +
+

Vector B

+ + + +
+
+ +
+ + + + + + +
+ +
+ +

Developed by TinkerTechie

+
+ + + + diff --git a/vector-calculation/script.js b/vector-calculation/script.js new file mode 100644 index 00000000..b4b10644 --- /dev/null +++ b/vector-calculation/script.js @@ -0,0 +1,54 @@ +function getVectors() { + const ax = parseFloat(document.getElementById('ax').value) || 0; + const ay = parseFloat(document.getElementById('ay').value) || 0; + const az = parseFloat(document.getElementById('az').value) || 0; + const bx = parseFloat(document.getElementById('bx').value) || 0; + const by = parseFloat(document.getElementById('by').value) || 0; + const bz = parseFloat(document.getElementById('bz').value) || 0; + + return { A: [ax, ay, az], B: [bx, by, bz] }; +} + +function calculateMagnitude() { + const { A, B } = getVectors(); + const magA = Math.sqrt(A[0]**2 + A[1]**2 + A[2]**2).toFixed(3); + const magB = Math.sqrt(B[0]**2 + B[1]**2 + B[2]**2).toFixed(3); + document.getElementById('results').innerHTML = `|A| = ${magA}, |B| = ${magB}`; +} + +function addVectors() { + const { A, B } = getVectors(); + const res = [A[0]+B[0], A[1]+B[1], A[2]+B[2]]; + document.getElementById('results').innerHTML = `A + B = (${res.join(', ')})`; +} + +function subtractVectors() { + const { A, B } = getVectors(); + const res = [A[0]-B[0], A[1]-B[1], A[2]-B[2]]; + document.getElementById('results').innerHTML = `A - B = (${res.join(', ')})`; +} + +function dotProduct() { + const { A, B } = getVectors(); + const res = (A[0]*B[0] + A[1]*B[1] + A[2]*B[2]).toFixed(3); + document.getElementById('results').innerHTML = `A · B = ${res}`; +} + +function crossProduct() { + const { A, B } = getVectors(); + const res = [ + A[1]*B[2] - A[2]*B[1], + A[2]*B[0] - A[0]*B[2], + A[0]*B[1] - A[1]*B[0] + ]; + document.getElementById('results').innerHTML = `A × B = (${res.join(', ')})`; +} + +function angleBetween() { + const { A, B } = getVectors(); + const dot = A[0]*B[0] + A[1]*B[1] + A[2]*B[2]; + const magA = Math.sqrt(A[0]**2 + A[1]**2 + A[2]**2); + const magB = Math.sqrt(B[0]**2 + B[1]**2 + B[2]**2); + const angle = Math.acos(dot / (magA * magB)) * (180/Math.PI); + document.getElementById('results').innerHTML = `Angle = ${angle.toFixed(2)}°`; +} diff --git a/vector-calculation/style.css b/vector-calculation/style.css new file mode 100644 index 00000000..1d247f0d --- /dev/null +++ b/vector-calculation/style.css @@ -0,0 +1,83 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap'); + +* { + margin: 0; + padding: 0; + font-family: "Poppins", sans-serif; + box-sizing: border-box; +} + +body { + background-color: #e3f9ff; + display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; +} + +.container { + background-color: #18355f; + color: white; + padding: 30px; + border-radius: 12px; + text-align: center; + width: 90%; + max-width: 600px; +} + +h1 { + margin-bottom: 20px; +} + +.vectors { + display: flex; + justify-content: space-between; + margin-bottom: 20px; +} + +.vector { + display: flex; + flex-direction: column; + gap: 10px; +} + +.vector input { + padding: 8px; + border-radius: 8px; + border: none; + width: 100px; + text-align: center; +} + +.buttons { + display: flex; + flex-wrap: wrap; + gap: 10px; + justify-content: center; + margin-bottom: 20px; +} + +button { + padding: 10px 15px; + border-radius: 8px; + border: none; + cursor: pointer; + font-size: 14px; + font-weight: 500; + background-color: #00bcd4; + color: white; + transition: 0.3s; +} + +button:hover { + background-color: #0097a7; +} + +.results { + background-color: white; + color: black; + padding: 15px; + border-radius: 8px; + min-height: 50px; + font-weight: 500; +}