Jump to content
  • Advertisement
Sign in to follow this  
teutoburger

Does anyone know a Matrix transformation like so?

This topic is 585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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

 

[attachment=34172:quad-01.png]

[attachment=34173:quad-02.png]

 

and

 

[attachment=34170:palm-01.png]

[attachment=34171:palm-02.png]

Share this post


Link to post
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 this post


Link to post
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 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!