Hello,(adsbygoogle = window.adsbygoogle || []).push({});

This question might seem silly, but I've tried some approaches and none of them seemed to work.

Here's my problem:

I need some sort of transform that maps points from any quad to an rectangle. I will be using this on a computer graphics software, so you can think of this rectangle as my viewport or something like that.

Below is an image to illustrate the problem:

The points 1, 2, 3 and 4, and the w and h values are parameters. The point P is the input, and I'd like to know P'. The point 1 should map to (0,0), the point 2 should map to (w,0) and so on...

Sorry if this is confusing. Please tell me if you need more information.

As I said, I've tried several approaches. The first one is to use the most basic matrix transform:

[tex]

\left( \begin{array}{c} x' \\ y' \end{array} \right) =

\left( \begin{array}{cc} a & b\\ c & d \end{array} \right)

\left( \begin{array}{c} x \\ y \end{array} \right)

[/tex]

Where x' and y' would be the coordinates of the output point P', and x and y would be the input point P.

Obviously this would never work (I think), because I have 4 points (1, 2, 3, 4) that should be considered, and therefore I have to build a system with all of them. That would give me 8 equations and 4 unknowns (a, b, c, d), which I believe implies that I need more degrees of freedom.

So I've tried something like that:

[tex]

\left( \begin{array}{c} x' \\ y' \end{array} \right) =

\left( \begin{array}{cc} a & b\\ c & d \end{array} \right)

\left( \begin{array}{cc} e & f\\ g & h \end{array} \right)

\left( \begin{array}{c} x \\ y \end{array} \right)

[/tex]

Which actually gives me 8 equations and 8 unknowns. So I tried building my system.

I've considered that these are the values for points 1, 2, 3, 4:

[tex]

P_1 = (k,l);

P_2 = (m,n);

P_3 = (o, p);

P_4 = (q, r);

[/tex]

Which, by multiplying on the previous equation, led me to these equations:

[tex]

(a*e + b*g)*k + (a*f + b*h)*l = 0 \\

(c*e + d*g)*k + (c*f + d*h)*l = 0 \\

(a*e + b*g)*m + (a*f + b*h)*n = w \\

(c*e + d*g)*m + (c*f + d*h)*n = 0 \\

(a*e + b*g)*o + (a*f + b*h)*p = 0 \\

(c*e + d*g)*o + (c*f + d*h)*p = h \\

(a*e + b*g)*q + (a*f + b*h)*r = w \\

(c*e + d*g)*q + (c*f + d*h)*r = h

[/tex]

The first two represents the point 1, which maps to (0,0), the second one represents point 2, which maps to (w,0), and so on.

But when I input this in Mathematica or Matlab, I get no solutions:

Mathematica said:in := Solve[(a*e+b*g)*k+(a*f+b*h)*l==0&&(c*e+d*g)*k+(c*f+d*h)*l==0&&(a*e+b*g)*m+(a*f+b*h)*n==w&&(c*e+d*g)*m+(c*f+d*h)*n==0&&(a*e+b*g)*o+(a*f+b*h)*p==0&&(c*e+d*g)*o+(c*f+d*h)*p==h&&(a*e+b*g)*q+(a*f+b*h)*r==w&&(c*e+d*g)*q+(c*f+d*h)*r==h,{a,b,c,d,e,f,g,h}]

out = {}What is wrong with my approach? Matlab said:>> syms a b c d e f g h k l m n o p q r w h;

>> S = solve(...

'(a*e + b*g)*k + (a*f + b*h)*l = 0',...

'(c*e + d*g)*k + (c*f + d*h)*l = 0',...

'(a*e + b*g)*m + (a*f + b*h)*n = w',...

'(c*e + d*g)*m + (c*f + d*h)*n = 0',...

'(a*e + b*g)*o + (a*f + b*h)*p = 0',...

'(c*e + d*g)*o + (c*f + d*h)*p = h',...

'(a*e + b*g)*q + (a*f + b*h)*r = w',...

'(c*e + d*g)*q + (c*f + d*h)*r = h', a, b, c, d, e, f, g, h);

Warning: Explicit solution could not be found.

> In solve at 179

Can someone tell me some way to solve this?

Thanks.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Transform that maps points from any quad to an reactangle

Tags:

Loading...

Similar Threads - Transform maps points | Date |
---|---|

I Solutions to equations involving linear transformations | Mar 6, 2018 |

I Affine transformation and coordinates of maps | May 13, 2017 |

Mapping Conditions in Transformational Space | Oct 2, 2012 |

Mapping ( linear transformation) | Nov 22, 2008 |

Function vs mapping vs transformation | Jul 21, 2007 |

**Physics Forums - The Fusion of Science and Community**