Sign in to follow this  
teutoburger

Does anyone know a Matrix transformation like so?

Recommended Posts

Is there a matrix that can tranform an object as shown in the image?

 

It can be a 2d matrix, but 3d would also be useful.

I realise it looks a bit like a perspective projection. 

But I just mean a matrix, which transforms / enlarges x values depending on their y value.

The higher the y value, the more x gets scaled up.

 

[attachment=34165:transform.png]

Share this post


Link to post
Share on other sites

No such matrix is possible, because that's not a linear transformation. The reason that projection matrices can get away with that sort of distortion is because of the division by w term, which makes the whole transformation nonlinear.

 

To see why, assume that M is a matrix that satisfies your desired transformation. It's easy to see that

 

zVKIFxU.gif

 

This is contradicts the fact that your transformation is linear.

Edited by CulDeVu

Share this post


Link to post
Share on other sites

No Matrix possible. ok.

 

I *think* this formula below kind of does what I need.

 

m_x is the average x value of the mesh.

 

y_min is the global minimum y value of the mesh.

 

delta = 1, doesn't change the mesh.

delta = 0, all x values are condensed into one spot the further you go up (maby there's something missing in the formula, I think it still also needs to process the overall height of the mesh somehow.)

delta > 1 expands x values outwards going up the mesh.

 

But they behave quite unpredictable, when x is changed upwards, the extent of expansion doesn't seem linear.

 

[attachment=34169:math_x_dash.png]

 

does anybody know of a better solution?

Edited by teutoburger

Share this post


Link to post
Share on other sites
You can always find a projective transformation that transforms one quadrilateral to another one. A projective transformation on the plane is represented by a 3x3 matrix.

See if something like this works:
 
(1  0 0)   (x)
(0 -1 0) * (y)
(0  1 1)   (1)

Remember that the resulting vector is in projective coordinates, which means approximately that you need to scale it to force the third coordinate to be 1. Edited by Álvaro

Share this post


Link to post
Share on other sites

that's just too good to pass :-P
Oh, you added it, instead of multiplying (optionally also multiplying with scale(y)), ie

 

x' = x * scale(y) * (1 + sin(y)) / 2

 

You may want to increase "1" slightly, as "1 + sin(y)" touches 0, ie every 2*pi the entire plane becomes a single point.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this