Kernel SDK Developer's Guide > Working with the Ge Library > Working with Curves > Working with Circular Arcs
Working with Circular Arcs

In the Ge library, circles and circular arcs are represented by OdGeCircArc2d and OdGeCircArc3d objects and inherit functionality of the OdGeCurve2d and OdGeCurve3d classes for 2D and 3D modeling space respectively. This topic demonstrates the most common operations with circular arcs as an object of the OdGeCircArc3d class. The functionality of 2D circular arc objects is similar except that 2D arc objects don't have methods for working with the normal vector. The classes for circular arcs are derived from the OdGeCurve2d and OdGeCurve3d classes respectively, so they have all the features of base curves. For more information, see Working with Curves.

An arc object is defined by the following parameters: arc's center point, radius, reference vector, start and end angles, and normal vector. The reference vector is a vector perpendicular to the normal and from which arc angles are measured. Angles are measured in a counterclockwise direction about the normal vector. A full circle is considered to be an arc that has the difference between the end and start angles of Oda2PI.

For creation of a circular arc object, you can use one of the OdGeCircArc3d() constructors:

  • OdGeCircArc3d::OdGeCircArc3d() — Default constructor. Constructs a circle with center at (0,0,0), normal of (0,0,1), and radius of 1.0.
  • OdGeCircArc3d::OdGeCircArc3d(const OdGeCircArc3d& source) — Creates a circular arc cloned from the source arc object.
  • OdGeCircArc3d::OdGeCircArc3d(const OdGePoint3d& center, const OdGeVector3d& normal, double radius) — Creates a full circle with specified center, normal and radius.
  • OdGeCircArc3d::OdGeCircArc3d(const OdGePoint3d& center, const OdGeVector3d& normal, const OdGeVector3d& refVec, double radius, double startAng = 0, double endAng = Oda2PI) — Creates a circular arc with specified center, normal, reference vector, radius, and start and end angles. If startAng and endAng aren't specified or they are 0 and Oda2PI respectively, then a full circle is created.
  • OdGeCircArc3d::OdGeCircArc3d(const OdGePoint3d& startPoint, const OdGePoint3d& secondPoint, const OdGePoint3d& endPoint) — Creates an arc through three non-coincident, non-collinear points.

Work with Properties of a Circular Arc

The OdGeCircArc3d class provides a set of methods for working with circular arc objects.

The center(), radius(), endAng(), startAng(), endPoint(), startPoint(), normal(), refVec(), and getPlane() methods are used to obtain the center, radius, end and start angles, end and start points, normal, reference vector, and plane on which a circular arc lies. To set arc properties, use the corresponding methods: setCenter(), setRadius(), setAngles(), setAxes() or one of the set() methods. For example:


OdGeCircArc3d arc1;
OdGePlane planeForCircArc;
arc1.set(OdGePoint3d(0,0,0), OdGeVector3d(0,0,1), OdGeVector3d(1,0,0), 2, 0, OdaPI);
arc1.setRadius(3);
OdGePoint3d p1 = arc1.center();
OdGePoint3d p2 = arc1.startPoint();
OdGePoint3d p3 = arc1.endPoint();
OdGeVector3d v1 = arc1.refVec();
arc1.getPlane(planeForCircArc);

Also, circular arc has an ability to be created by three points. This variant has limitations:

  • points must not be collinear;
  • you cannot create a closed/full circle, only an arc

Source code example is presented below:


OdGeCircArc3d circArc3d;
OdGePoint3d firstPoint(2.4606, 4.7965, 0);
OdGePoint3d secondPoint(6.4305, 11.4500, 0);
OdGePoint3d thirdPoint(16.4469, 7.7265, 0);
circArc3d.set(firstPoint, secondPoint, thirdPoint);

For 3D circle arcs, the positive direction for the angles is counter-clockwise looking to the origin of the normal vector. Reversing the normal vector to the opposite causes the arc to change direction with adjusting the start and end angles. 2D arc objects don't have the normal and they can be clockwise or counterclockwise oriented. To check the orientation, use the OdGeCircArc2d::isClockWise() method, which returns true if the arc has clockwise orientation. And to reverse the direction of the arc while maintaining its endpoints, use the setToComplement() method. On the left side you can see a circular arc created clockwise. On the right side a circular arc is created with the clockwise parameter set to false.

Note: clockwise flag doesn’t change parametrization (start angle and end angle). The curve interval remains unchanged. Clockwise direction is achieved by reversing minor axis.

The isClockWise() methods allow you to check arc's direction.

The isInside() method determines whether the specified point lies inside the full circle of this arc and is on the same plane as this arc:

bool isInside = arc1.isInside(p1);

Calculate Closest Point to a Plane

The OdGeCircArc3d class provides the closestPointToPlane() method that calculates the distance between the closest point on this arc and the specified point on the passed plane.

  • plane — Any planar entity that contains a point to which the closest point is calculated.
  • pointOnPlane — Point on planar entity.
  • tol — Geometric tolerance.

In the next example, the plane is a plane that contains a point to which the closest point on this arc is calculated.


OdGePoint3d closestPoint = arc1.closestPointToPlane(plane, OdGePoint3d(0.0, 0.0, 0.0));

Calculate Intersections

To calculate intersections between this circular arc and other objects, use one of the intersectWith() methods and the projIntersectWith() method. The methods require the following parameters:

  • %object% — Parameter names can be line, arc or plane which represent an object with which intersections should be calculated.
  • numInt — Number of intersections between this arc and a passed object.
  • p1 — First intersection point.
  • p2 — Section intersection point.
  • tol — Geometric tolerance.

The method returns true if at least one intersection point is retrieved, or false otherwise.


OdGeLine3d line;
line.set(OdGePoint3d(0.0, 0.0, 0.0), OdGePoint3d(0.0, 2.0, 0.0));
int intersectionCnt;
OdGePoint3d intP1;
OdGePoint3d intP2;
bool bIntersected = arc1.intersectWith(line, intersectionCnt, intP1, intP2);

Calculate Geometric Extents

You can calculate geometric extents of a circular arc which can be useful for many reasons. One of the most obvious examples is zooming a view to the extents of an arc. Use the getGeomExtents() extents to retrieve geometric extents, for example:


OdGeExtents3d ext;
arc1.getGeomExtents(ext);

Calculate Tangents

You can check if there is a tangent line to a full circle at a specified point using one of the tangent() methods. The methods require the following parameters:

  • point — Point on the full circle for which to calculate the tangent.
  • line — Receives the tangent line if it exists at the passed point.
  • tol — Geometric tolerance.

One of the methods also accepts the OdGeError& status parameter which receives the result of method execution. The kOk value is received if the method finishes successfully and the tangent is retrieved.


OdGeLine3d& line; 
OdGeError& status;
bool bTangent = arc1.tangent(OdGePoint3d(0.0, 1.0, 1.0), line, OdGeTol(), status);

Join Circular Arcs

You can join another circular arc with this circular arc using the joinWith() method. There are some conditions that need to be met to join a passed arc:

  • Curves should not overlap.
  • Circles should have the same center.
  • Circles should have the same radius.
  • Normals of circles should be co-directional.
  • End point of this curve should match the start point of the passed curve.

If one of the conditions fails, the method throws the eInvalidInput error. The angle between the corresponding axes can be arbitrary. For example:


OdGeCircArc3d curveToJoin;
curveToJoin.set(OdGePoint3d(0.0, 0.0, 0.0), OdGePoint3d(1.0, 1.0, 0.0), OdGePoint3d(2.0, 0.0, 0.0));
OdGeCircArc3d joinedCurve = arc1.joinWith(curveToJoin);

Reverse Parameters

The reverseParam() methods reverse arc's directions. For example you created an arc with the following code:


...
OdGeCircArc3d circArc3d;
circArc3d.setInterval(OdGeInterval(0., OdaPI2));
...

The created 3D arc has equal parameters and angles 0 .. Pi/2. The created arc has start point at [1,0,0] and end point at [0,1,0].

Note: angles and parameters are equal at this moment. Major axis shows zero angle, arc's direction is counterclockwise.

The following code reverses arc parameters:


circArc3d.reverseParam(); 
//
// reverse direction of arc
//

After reversing arc's geometry is changed inside, changes are hidden. The reversed arc has start point at [0,1,0], end point at [1,0,0] which means that the order of arc points is reversed. Major axis shows 0 angle, so the start angle is OdaPi/2 and end angle is OdaPi (circle arc has equal major and minor axes). Arc's direction is now clockwise.

Note: angles and parameters are not related, you shouldn't mix their usage. For instance, see code example with correct and incorrect usage of arcs:


//This code gives different points.
OdGePoint3d first(-10., 2., 0), second(-7.6568542494923806, 7.6568542494923806, 0), third(-2., 10, 0);
OdGeCircArc3d arc3d(first, second, third);
arc3d.reverseParam();
OdGePoint3d point3d1 = arc3d.evalPoint(arc3d.startAng());
OdGePoint3d point3d2 = arc3d.startPoint();
// NOTE: point3d1 is not equal to point3d2


//=====================================


//But this code gives equal points.

OdGePoint3d first(-10., 2., 0), second(-7.6568542494923806, 7.6568542494923806, 0), third(-2., 10, 0);
OdGeCircArc3d arc3d(first, second, third);
OdGeInterval intervall;
arc3d.getInterval(intervall);
OdGePoint3d point3d1 = arc3d.evalPoint(intervall.lowerBound());
OdGePoint3d point3d2 = arc3d.startPoint();
// NOTE: point3d1 is equal to point3d2

The reversing functionality is available in OdGeEllipArc3d\2d and OdGeCircleArc3d\2d classes.

See Also

Working with Elliptical Arcs

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.