Rotation around a fix axis

Hy forum,

who knows how to rotate a TopoDS_Shape around an arbitrary fix axis im 3 dimensions (not the xyz-axis)?

Is there alredy something implemented or should I invent myself ?

I only found gp_Trsf etc with methods for rotation/translation, but nowhere how to fix the axis around which the shape shall be rotated.

Best Regards and thanks in advance


Rob Bachrach's picture

Maybe I misunderstand your question, but you should be able to create the appropriate transformation with gp_Trsf::SetRotation(const gp_Ax1 A1, const Standard_Real Ang). Use the resulting transform to create a BRepBuilderAPI_Transform and use that to transform your shapes.

MCV's picture

Thank you a million times.
That was a wonderful hint and it solved the problem.

The only strange thing is, that there is a formula (a matrix) in some math books for the rotation around a general axis and if you set this matrix via "SetRotationalPart"
and then transform some shapes, the roatation-angle becomes too big and their is a visible stretch-effect of all shapes. This shall not be the case, the areas and volumes of the shapes should be the same as before the transformation.
Does someone have an idea why ?

Best Regards


Rob Bachrach's picture

I am not sure where "SetRotationalPart" is defined, but...
If the function is similar to SetTranslationPart, it probably only sets the 3x3 rotation matrix. This can only rotate about an axis passing through the origin. Which, if you are rotating an object that is off the origin, this could cause distortion. In order to perform a rotation about an arbitrary axis, the matrix must include both a rotation and a translation. In essence, think of it as the shape and axis being translated so the axis passes through the origin. Then, the rotation is performed. Finally, the shape is translated back.

SetRotation computes the rotational and translational parts of the matrix.