# Homography matrix

Hello,

I'm taking different views of a TopoDS_Shape created from the reading of a STEP file. To do that, I'm moving the camera around X, Y and Z world axis establishing the look-at point (center view) always at the center of mass of the shape. Now I need to calculate the homogeneous matrix (4x4) that transform points from the View Coordinate system into the camera coordinate system. How can I do that?

Another question, is it possible to change the location of the world coordinate system to the center of mass of the shape and then calculate the homogeneous matrix directly between the world coordinate system and the camera system?

Thanks!

The transformations in OCCT are defined by gp_Trsf class, which can be initialized in various ways, including translation and transformation from one coordinated system to another (defined by gp_Ax2/gp_Ax3 classes).
gp_Trsf::GetMat4() method can be used to define a 4x4 matrix (used in visualization), while gp_Trsf stores transformation in decomposed way.

Hello,

Now I'm dealing with the opposite problem. How can I define a gp_Trsf from a given matrix 4x4?

Thanks!

Arbitrary 4x4 transformation matrix cannot be represented by gp_Trsf - see documentation of this class.
4x3 transformation matrix can be initialized using gp_Trsf::SetValues() method.

And then, why does the method GetMat4 exist? If I use the three first columns of this matrix in the function SetValues, should I get the correct result?

You should read about transformation matrices (as well as documentation of related OCCT classes).

4x3 matrix is a convenient way for storing 4x4 matrix with one row being (0, 0, 0, 1), e.g. as in identity matrix - and this is what gp_Trsf::GetMat4() will return.
This is enough for a "normal" transformation, where 3x3 matrix within 4x3 stores rotation part (and scale) and the 4th column stores translation part.

Obviously, the arbitrary 4x4 matrix cannot fit into 4x3. For example, perspective projection matrix cannot be defined by gp_Trsf (and is not supposed to).

Dear Kirill I want to get help from you about converting the mouse coordinates to world coordinates if you help i will be very happy.

I Tried to convert by ConvertToClickToWorld as in forums , I want to make a snap function but it gives wrong coordinates .

is there any other safe way to convert mouse coordinates to world coordinates .(I use qt)

Thank you very much.