Vector addition in Mag & Dir form

Developer
Size
2,347 Kb
Views
4,048

How do I make an vector addition in mag & dir form?

What is a vector addition in mag & dir form? How do you make a vector addition in mag & dir form? This script and codes were developed by Yoann Nouveau on 19 December 2022, Monday.

Vector addition in Mag & Dir form Previews

Vector addition in Mag & Dir form - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Vector addition in Mag & Dir form</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
</head>
<body> <script src="js/index.js"></script>
</body>
</html>

Vector addition in Mag & Dir form - Script Codes JS Codes

"use strict";
function round(a) { return Math.round(a * 100) / 100;
}
function addVector(w, x) { var y = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2]; var z = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3]; //convert a and b to compound form A and B x = x * Math.PI / 180; z = z * Math.PI / 180; var A = { x: round(w * Math.cos(x)), y: round(w * Math.sin(x)) }, B = { x: round(y * Math.cos(z)), y: round(y * Math.sin(z)) }; //add them together var C = { x: round(A.x + B.x), y: round(A.y + B.y) }; C.mag = Math.pow(Math.pow(C.x, 2) + Math.pow(C.y, 2), 1 / 2); C.dir = Math.atan(C.y / C.x) * 180 / Math.PI; C.mag = round(C.mag); C.dir = round(C.dir); //Quadrant adjustment if (C.x < 0 && C.y > 0 || C.x > 0 && C.y < 0) { //Quad II & III C.dir += 180; } else if (C.x < 0 && C.y < 0) { //Quad IV C.dir += 360; } console.clear(); console.log(C); return C;
}
addVector(7, 160, 9, 20);
Vector addition in Mag & Dir form - Script Codes
Vector addition in Mag & Dir form - Script Codes
Home Page Home
Developer Yoann Nouveau
Username YoannN2
Uploaded December 19, 2022
Rating 3
Size 2,347 Kb
Views 4,048
Do you need developer help for Vector addition in Mag & Dir form?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Yoann Nouveau (YoannN2) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!