Forum archiveIssue archiveModeling Data and Algorithms

Archived discussion

why the object is not rotating around its own axis. resultShapetrf2 should be positioned between trf1 and trf2.

Modeling Data and AlgorithmsWed, 08/30/2023 - 10:041 reply

Browse this forum
QuestionAuthor

int main()
{

BRepPrimAPI_MakeSphere shpherMaker1( 10.0 );
TopoDS_Shape shpere = shpherMaker1.Shape();

BRepPrimAPI_MakeSphere shpherMaker1( 10.0 );
TopoDS_Shape shpere1 = shpherMaker1.Shape();

BRepPrimAPI_MakeSphere shpherMaker2( 10.0 );
TopoDS_Shape shpere2 = shpherMaker2.Shape();

gp_Trsf transform;
transform.SetValues( 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1, 0 , 0 , 0 );
BRepBuilderAPI_Transform trf( sphere , transform );

gp_Trsf transform1;
// transform1.SetValues( 1 , 0 , 0 , 0 , 0 , 1,0 , 1000 , 0 , 0, 1, 0 );
transform1.SetValues( 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1000 , 1 , 0 , 0 , 0 );
BRepBuilderAPI_Transform trf1( shpere1 , transform1 );

gp_Trsf transform2;
transform2.SetValues( 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1050 , 1 , 0 , 0 , 0 );
BRepBuilderAPI_Transform trf2( shpere2 , transform2 );

BRepAlgoAPI_Fuse booleanOperation( trf1.Shape() , trf2.Shape() );
TopoDS_Shape resultShape = booleanOperation.Shape();
gp_Trsf transform3;
transform3.SetValues( 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 );
BRepBuilderAPI_Transform resultShapetrf2( resultShape , transform3 );

TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound( compound );
builder.Add( compound , trf );
builder.Add( compound , trf1 );
builder.Add( compound , trf2 );
builder.Add( compound , resultShapetrf2 );
BRepTools::Write( compound , "d:/ddddddddddddddddd.brep" );

}

Discussion

1 archived reply

Posts are displayed in their archived order.

01Commenter-1

Hello,

Your matrix looks invalid. there zero scaling. And something wrong with elements on matrix. Please check the transform matrix representation on OCCT.

//!    V1   V2   V3    T       XYZ        XYZ
//! | a11  a12  a13   a14 |   | x |      | x'|
//! | a21  a22  a23   a24 |   | y |      | y'|
//! | a31  a32  a33   a34 |   | z |   =  | z'|
//! |  0    0    0     1  |   | 1 |      | 1 |

Diagonal elements - scaling.

Best regards, Commenter-1.