e.bf
e.bf

Reputation: 13

How to map 2d point from one coordinate system to another

I have some source points which are between (0,100) imagine a coordinate system top left of that is (0,0) and bottom right is (100,100). And destination coordinate system is a space between (-1/2, 1/2). some points are like this :

 x=0,y=0  --->  x'=-1/2,y'=1/2
 x=50,y=50  --->  x'=0,y'=0
 x=100,y=100  --->  x'=1/2,y'=-1/2

Now how can I map any point from first coordinate to the second? any help really appreciate.

Upvotes: 1

Views: 1931

Answers (1)

Shahar Bental
Shahar Bental

Reputation: 1001

I'm assuming a linear transformation is what you are looking for.

So x->ax+b, y->cy+d

Generally, start with the (0,0), as that's easier 0->b and 0->d, so b=-1/2, d=1/2

And now trivially comes the rest 50->50a-1/2=0 so a=1/100, and 50c+1/2=0 so c=-1/100

Overall, use x->x/100-1/2 and y->-y/100+1/2

Upvotes: 2

Related Questions