## DEV Community is a community of 871,998 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Cesar Del rio

Posted on • Updated on

# #1 - Points of reflection (8 kyu) Codewars Kata

## #1 - Points of reflection (8 kyu)

Instructions:
"Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.

Given two points P and Q, output the symmetric point of point P about Q. Each argument is a two-element array of integers representing the point's X and Y coordinates. Output should be in the same format, giving the X and Y coordinates of point P1. You do not have to validate the input.

My notes: My solution:

``````function symmetricPoint(p, q) {
return [2*q-p, 2*q-p ]
}
``````

Explanation
I found the formula for getting the P1 coordinate, the formula is P1(2Qx - Px, 2Qy - Py), then I just passed this formula with the array index positions and returned the result as an array