ghorwin

10th December 2019, 17:43

Hi there,

I'm wondering whether you'd have a suggestion on how to create and position a plane in 3D space using the Qt3DExtra types.

Specifically, I have defined the target rectangular plane through points in space (p_i, i=0,1,2).

I first create a plane using Qt3DExtras::QPlaneMesh providing the width w and height h of the given plane (width and height from vectors p_2-p_0 and p_1 - p_0). The plane mesh is created in the x-z plane (positive y-axis being the normal vector), and centered around w/2 and h/2. The points t_i of the newly created plane in world coordinates corresponding the my points p_i are (-w/2, 0, -h/2), (w/2,0,-h/2), and (-w/2, 0, h/2).

Now I want to rotate and translate the plane entity to be positioned at my world coordinates p_i. My current approach involves creating a transformation matrix for world coordinates with QQuaternions and manually transforming the plane offset (w/2, h/2) (to move the lower left point of the matrix to the origin) into the mapped coordinates and add it to the local coordinate system origin p_0.

This feels kind of complicated so here's my question: can you come up with a smoother/fancy or just faster solution?

Thanks a ton,

Andreas

I'm wondering whether you'd have a suggestion on how to create and position a plane in 3D space using the Qt3DExtra types.

Specifically, I have defined the target rectangular plane through points in space (p_i, i=0,1,2).

I first create a plane using Qt3DExtras::QPlaneMesh providing the width w and height h of the given plane (width and height from vectors p_2-p_0 and p_1 - p_0). The plane mesh is created in the x-z plane (positive y-axis being the normal vector), and centered around w/2 and h/2. The points t_i of the newly created plane in world coordinates corresponding the my points p_i are (-w/2, 0, -h/2), (w/2,0,-h/2), and (-w/2, 0, h/2).

Now I want to rotate and translate the plane entity to be positioned at my world coordinates p_i. My current approach involves creating a transformation matrix for world coordinates with QQuaternions and manually transforming the plane offset (w/2, h/2) (to move the lower left point of the matrix to the origin) into the mapped coordinates and add it to the local coordinate system origin p_0.

This feels kind of complicated so here's my question: can you come up with a smoother/fancy or just faster solution?

Thanks a ton,

Andreas