简体   繁体   中英

Scale and translate path from one coordinate system to another

I have a path output as shown in the image below, in a coordinate system 1 wherein the start point and the end point are (40,40) and (10,20) respectively.

I want to scale this path to a new coordinate system (coordinate system 2) with a known start and end point, the path has to scale and adjust between the new points.

I believe Affine transforms might help / linear algebra. How do I achieve this? and will this be accurate or will it distort?

显示两个坐标系的图像

To find appropriate affine tranformation (there are many ways to transform two points into two another ones, but we choose the simplest way), you can apply these elementary steps:

Shift coordinates by (-startx, -starty) 
Scale along X-axis with coefficient (newendx-newstartx)/(endx-startx)  (here -80/3)
Scale along Y-axis with coefficient (newendy-newstarty)/(endy-starty)   (here -35)
Shift coordinates by (newstartx, newstarty) 

Resulting affine tranformation is product of these four matrices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM