I have a chart like this: 

![Before](https://i.stack.imgur.com/LtqvR.png)

Point O is in a rectangle and dependent to rectangle edges.

After I drag point B (corner), the rectangle is deformed like this:

![After](https://i.stack.imgur.com/pHSsU.png)

How I can calculate the coordinates of point O after deformation?

I work in JavaScript, so if You could, I would like an algorithm. Thanks for all and sorry for english bads!