Challenge 41

🎱

Vector Addition - Simulating Collisions

Open in Code Editor or Copy Instructions
...solutions at bottom of page...

We are modelling a collisions of objects. When another object collides with it, it will exert a force on the original

Create a function that can take add an arbitrary number of vectors and output the result

Examples:

Suppose input vectors of (1,2), (3,4), the result would be x: 4, y: 6

Suppose input vectors of (1,2), (3,4), (-5,-6), the result would be x: -1, y: 0

Extension:

Using the Pythagorean Theorem, calculate the magnitude of the resultant vector - i.e. the square root of the x-component squared added to the y-component squared

Solutions

IGCSE 0478 / O-Level 2210 A-Level 9618