0

I need to calculate a 4x4 matrix (for OpenGL) that can transform a 3d object on the left to one on the right. Transformation applied only in one axis.

desired result

EDIT:

The inputs are a given 3d object (points) to be deformed and a single variable for the amount of deformation.

A picture represents a cube projected to plane showing only relevant changes. There are no changes in the axis perpendicular to view plane.

The relative position of these two objects is not relevant and used only to show "before and after" situation.

Yevheniy8
  • 63
  • 8
  • 2
    There are several ways of doing that. Indeed, there are *infinitely many* ways of doing that. Since the visual result is 2D, but the inputs are 3D, it's impossible to say which matrix was used to do the transformation. – Nicol Bolas Feb 23 '20 at 15:54
  • What does " Transformation applied only in one axis" mean? – derhass Feb 23 '20 at 16:04
  • FYI: [SO: How to paint / deform a QImage in 2D?](https://stackoverflow.com/a/56970955/7478597) – Scheff's Cat Feb 23 '20 at 16:21
  • Did you mean 3×3 matrix? 4×4 matrix makes no sense at all in this case. – ALX23z Feb 23 '20 at 17:52
  • @NicolBolas, care to elaborate what is exactly the information missing from my question? – Yevheniy8 Feb 23 '20 at 21:50
  • You do not describe what kind of transformation you are looking for, the statement "transformation applied only in one axis" is in contradiction to the picture where both `x` and `y` dimensions are affected (the intersection point of the diagonals moves in x), and "a single variable for the amount of deformation" is lacking a proper definition of how that variable is supposed to affect the outcome. – derhass Feb 27 '20 at 15:33
  • If you did not specify that "The inputs are a given 3d object" I'd say that you are just looking for a standard homography matrix, but that will affect the third dimension when applied to 3D data. – derhass Feb 27 '20 at 15:36
  • @derhass there's no vertex in the intersection you're talking about. The "single variable" affects the outcome linearly – Yevheniy8 Mar 02 '20 at 18:09
  • There is no need for a vertex being at the interception. A transformation matrix transforms every point in the mathematical space. If you want the transformation to not affect the horizontal dimension, you would have to draw your image differently. Actually, you would have to _bend_ the diagonals and end up with a non-linear transformation not expressible with matrix multiplication at all. – derhass Mar 02 '20 at 21:08
  • And please not that this does affect the rendering with the GL also even if you apply the transformation to the outer vertices only, because it will influence the interpolation in-between via the perspecitve correction, which is crucial for your use case. – derhass Mar 02 '20 at 21:17

1 Answers1

0

******* wrong answer was here *******

It's somewhat opposite to 2D perspective matrix with further perspective division. So, to do this "perspective" thing inversely, you need to do something opposite to perspective division then multiply the result by an inverted "perspective" matrix. And though the perspective matrix may be inverted, I have no idea what is "opposite to perspective division". I think you just can't do it with matrices. You'll have to transform Y coord of each vertex instead

Clubs
  • 31
  • 5