Thu, 06/29/2017 - 10:30

Forums:

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!

Thu, 06/29/2017 - 14:12

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.

Tue, 12/19/2017 - 19:23

Hello,

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

Thanks!

Tue, 12/19/2017 - 21:16

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.

Wed, 12/20/2017 - 10:23

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?

Thu, 12/21/2017 - 21:39

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

Wed, 02/27/2019 - 16:58

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.

Selahattin BABADAG

Civil Eng.

Wed, 02/27/2019 - 19:53

Having only mouse position gives you an infinite number of 3D positions along the ray, hence it is not well-defined operation - you need defining some plane / grid in 3D.

In contrast, picking 3D point on a Shape under mouse cursor makes sense, and it can be directly

SelectMgr_ViewerSelectorafter AIS_InteractiveContext::MoveTo() - see Draw Harness commandvstateas example.Thu, 03/05/2020 - 14:52

Dear Kirill ; my aim is to freely move the mouse cursor and get the real world coordinates on space near an object , it is successful if the view is a plane view like XY XZ... but in a 3d occ view all returned results are wrong..., so how do the user can move the mouse in 3d space and get the current real coordinate to start a new drawing a line , a circle etc?

I coudnt succeed.