# 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 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

Edited by CulDeVu

##### 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 on other sites
x' = x * scale(y)

That worked.

Just had to make sure that the mesh is centered at the y axis and sits on y=0

and

[attachment=34170:palm-01.png]

[attachment=34171:palm-02.png]

Looks nice :)

##### Share on other sites

I was planning to use this transformation for constructing more complicated meshes from simple canonical meshes.

But it surely could be used for when the player is on drugs. :-)

##### Share on other sites

Throw a "(1 + sin(time)) / 2" scale function in for some more wavey visuals :)

sin(y)  may also work :p

Edited by Alberth

##### Share on other sites

sin(y)  may also work

that's just too good to pass :-P

[attachment=34175:sin-palm.png]

##### 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 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.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628347
• Total Posts
2982204

• 10
• 9
• 24
• 11
• 9