I was wondering how solidworks calculate the transform matrix. I want to know what kind of algorithm it is using. Thanks a lot.
I hope you are interested in below calculations.
When every entity of a geometric model remains parallel to its initial position, the rigid-body transformation of the model is defined as translation. Translating a model implies that every point on it moves an equal given distance in a given direction.
Xnew = Xold + difference
Ynew = Yold + difference
Znew = Zold + difference
Simplified interface for manipulating transformation matrix data:
|a b c . n |
|d e f . o |
|g h i . p |
|j k l . m |
The SolidWorks transformation matrix is stored as a homogeneous matrix of 16 elements, ordered as shown. The first 9 (a to i) are elements of a 3x3 rotational sub-matrix, the next 3 (j,k,l) define a translation vector, the next 1 (m) is a scaling factor. The last 3 elements (n,o,p) are unused in this context.
The 3X3 rotational sub-matrix represents 3 axis sets: row 1 for x-axis components of rotation, row 2 for y-axis components of rotation, and row 3 for z-axis components of rotations. The 3 axes are constrained to be orthogonal and unified so that they produce a pure rotational transformation. Reflections can also be added to these axes by setting the components to negative. The rotation sub-matrix coupled with the lower-left translation vector and the lower-right corner scaling factor creates an affine (a transformation that preserves lines and parallelism, i.e., maps parallel lines to parallel lines) transformation. (All this information is available in SolidWorks API Help.)
This might help you.
Thanks and Regards,
Matrix transformations are functions of OpenGL. 16х16 like in SW is explained here.
I mean I want to know how Solidworks realize the function "Get_Transform2" of IComponent2. In other words, If I know the positions of a IComponent2 at time t1 and time t2. How to calculate the underlying transformation matrix?
I do not think there are any algorithms behind this API. Most likely the transforms are assigned once you move or mate components and ::Transform2 just returns this values.
I have added the macro which shows how two find the transformation between two selected components to myIntercad.myToolkit: SolidWorks API Tutorials/How To.../Transformation/Get The Transformation Between Components (id=99).
Feel free to download this macro.
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
myIntercad – an integrated tool for SolidWorks Professionals
LinkedIn SolidWorks API Education Group
" the transforms are assigned", where is the transform matrix is from??? I mean that if I am not allowed to use the function Get_Transform2, How could you realize the function from data before transform and data after transform. How to calculate the rotation and translation not from the function Get_Transform2
I am now doing this because my mentor wants to check the correctness of the function. crazy and annoy question
Ok, you can find how the Top/Front/Right Planes and Origin of components transformed regarding to the same entities of top assembly. This is the transformation of the component.
still confused. could you give me some pictures?
At this picture the Front/Right/Top planes of component coincide with the Front/Right/Top planes of assembly. The both origins also coincide.
That means that the component has 0 transformation matrix.
1 0 0 0
At this picture component moved and rotated. In order to find the transformation you should use the transformation of origin to identify the translation part of the transform and the rotation of planes to identify the rotation sub matrix. You may also need to consider the scale if any.
Refer the vector mathematics of how to build matrix having this data: https://en.wikipedia.org/wiki/Transformation_matrix
how could you calculate the translation?
I think you need to take a class or something. 3-D transformation matrices are not something you can teach someone over an internet forum.
I know how to get the transformed points after transformation, But my question is how to calculate the transformation matrix if I do not know it.
Ok, I think I have found the answer!!!!! Once again, I am disappointed with the reply!
The algorithm is stated in the paper"Estimating 3-D rigid body transformations: a comparison of four major algorithms". Four types of methods are described. I calculated using the first method and found the value is extremely close to the value using API function. I hope someone could tell me which is used in solid works!
In my case, there is no " transformation of origin", only trajectories of three points are available.
helps me a lot~
Retrieving data ...