wcandillon / can-it-be-done-in-react-native

⚛️ 📺 Projects from the “Can it be done in React Native?” YouTube series
https://www.youtube.com/wcandillon
MIT License
4.07k stars 1.31k forks source link

How to get the original coordinate after transform #182

Open richardcoder opened 1 year ago

richardcoder commented 1 year ago

Thanks in advance for such a good transform solution and good tutorial video: https://www.youtube.com/watch?v=yBuhnVDXekQ

I apply pinch/pan gesture detectors as shown in video to enable user to zoom in/zoom out and translate a picture. It works perfectly.

In addition, I want to add a tap detector to enbale user to draw path on the canvas, which is used to allow user to select special area on the picture. However, after transformation, the coordinate of tap detector event.x and event.y also get 3D Affine Transform and the path is not drawn at where user press at.

I want to ask if there is a reverse function of multiply4 which accept the 1x3 vector and transform matrix to get the original coordinate before transformation? Or should I write by myself according to the reference material ?https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html

Thanks a lot and looking forward to your reply!

wcandillon commented 1 year ago

I am not sure what you mean exactly, the invert matrix transformation can get you from the result vector to the original vector, not sure if this helps.