why is GC_MakeArcOfCircle function not behaving as expected?

easternbun

CAD practitioner
gp_Pnt _location = gp_Pnt(); gp_Ax2 _circle_axis(_location, m_axis); gp_Circ _circle(_circle_axis, m_centerpoint.Distance(m_startpoint)); GC_MakeArcOfCircle _arc(_circle, m_startpoint, alpha_angle, Standard_True);
None of arc built with this function start at the m_startpoint but at random points on given _circle.
1691573377351.png
 

blobfish

CAD community veteran
I looked into this briefly and have a couple of points to make.

1) you are using the constructor of gp_Ax2 that only takes one axis, the normal/z axis. OCCT is deriving the x axis. That x axis is currently unknown in your code.

2) the radian angle in the GC_MakeArcOfCircle constructor is from that unknown x-axis, NOT the start point.

Here is the code and associated output for a test I did. I am assuming that because I passed in the absolute z vector that occ used the absolute x axis for the gp_Ax2. I didn't take the time to check. So you will need to calculate angle from the x axis to use your current construction. IMHO: I am not sure what your goal is, but assuming you are going to make an TopoDS_Edge I would try:
create a vertex from you start point.
create a gp_Ax1 from your center point and normal.
create an edge using BRepPrimAPI_MakeRevol and vertex and axis.

Code:
  gp_Pnt center;
  gp_Pnt POC(1.0, 1.0, 0.0);
  double radius = POC.Distance(center);
  double angle = M_PI / 180.0 * 90; //radians
 
  gp_Ax2 system(center, gp_Dir(0.0,0.0,1.0));
  gp_Circ circle(system, radius);
 
  GC_MakeArcOfCircle arcMaker(circle, POC, angle, true);
  BRepBuilderAPI_MakeEdge edgeMaker(arcMaker.Value());

makeArcOfCircle.png
 

easternbun

CAD practitioner
I looked into this briefly and have a couple of points to make.

1) you are using the constructor of gp_Ax2 that only takes one axis, the normal/z axis. OCCT is deriving the x axis. That x axis is currently unknown in your code.

2) the radian angle in the GC_MakeArcOfCircle constructor is from that unknown x-axis, NOT the start point.

Here is the code and associated output for a test I did. I am assuming that because I passed in the absolute z vector that occ used the absolute x axis for the gp_Ax2. I didn't take the time to check. So you will need to calculate angle from the x axis to use your current construction. IMHO: I am not sure what your goal is, but assuming you are going to make an TopoDS_Edge I would try:
create a vertex from you start point.
create a gp_Ax1 from your center point and normal.
create an edge using BRepPrimAPI_MakeRevol and vertex and axis.

Code:
  gp_Pnt center;
  gp_Pnt POC(1.0, 1.0, 0.0);
  double radius = POC.Distance(center);
  double angle = M_PI / 180.0 * 90; //radians
 
  gp_Ax2 system(center, gp_Dir(0.0,0.0,1.0));
  gp_Circ circle(system, radius);
 
  GC_MakeArcOfCircle arcMaker(circle, POC, angle, true);
  BRepBuilderAPI_MakeEdge edgeMaker(arcMaker.Value());

View attachment 683
awww, I see.
yes those are the points I overlooked, thank you very much!
 
Top