For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

gp_Dir problem

Anonymous's picture
Forums: 

Dear all,

when I run the following code,

#include
#include
#include
#include
#include
#include
#include
#include

#include
#include
#include
#include
#include

#include
#include
#include

int main(int argc, char **argv){

gp_Ax2 Ax2, Bax;
gp_Ax1 Ax1(gp_Pnt(0.,0.,0.),gp::DZ());
Ax2.SetLocation(gp_Pnt(0.,0.,0.));
Bax = Ax2.Rotated(Ax1,0.8);
Ax1.SetDirection(gp::DX());
Bax = Bax.Rotated(Ax1,0.8);
TopoDS_Shape C1 = BRepPrimAPI_MakeCylinder(Bax,20.,20.).Shape();
for (TopExp_Explorer exp (C1,TopAbs_FACE);exp.More();exp.Next()) {
TopoDS_Face theFace = TopoDS::Face(exp.Current());
BRepAdaptor_Surface BS(theFace,Standard_True);
GeomAdaptor_Surface aSurface = BS.Surface();
if (aSurface.GetType() == GeomAbs_Cylinder){
gp_Cylinder myCylinder = aSurface.Cylinder();
gp_Ax3 myAxis = myCylinder.Position();
gp_Dir theDirect = myAxis.Direction();

cout

}
}
}

I get the following result for the main axis direction of the cylinder:

Cylinder gp_Dir: -2.52619e-17 -0.717356 0.696707

actually the first coordinate should be zero or is this a precision problem? And how can I avoid such small values in direction computation?

Thanks
Mark