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

In the Ge library, ellipses and elliptical arcs are represented by OdGeEllipArc2d and OdGeEllipArc3d 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 elliptical arcs as objects of the OdGeEllipArc3d class. The functionality of 2D elliptical arc objects is similar.

An elliptical arc object is defined by the following parameters: arc's center point, start and end angles, major and minor axes, major and minor radii, and normal vector. Angles are measured in a counterclockwise direction about the normal vector from the major axis. The start point is the point from which the ellipse is drawn, and the end point is the point to which the ellipse is drawn. A full ellipse is considered to be an arc which has the difference between the end and start angles of Oda2PI.

The angle of a point on an ellipse is measured by projecting the point along a vector perpendicular to the major axis onto a circle that has a center that is the center of the ellipse and radius that is the major radius of the ellipse. The angle between the major axis of the ellipse, and a vector from the center of the ellipse to the intersection point with the circle, measured counterclockwise about the crossproduct of the major and minor axes, is the angle of the point on the ellipse.

For creation of an elliptical arc object, you can use one of the OdGeEllipArc3d() constructors:

  • OdGeEllipArc3d::OdGeEllipArc3d() — Default constructor. Constructs a circle with center at (0,0,0), normal of (0,0,1), and radius of 1.0.
  • OdGeEllipArc3d::OdGeEllipArc3d(const OdGeCircArc3d& source) — Creates an elliptical arc cloned from the source arc object.
  • OdGeEllipArc3d::OdGeEllipArc3d(const OdGePoint3d& center, const OdGeVector3d& majorAxis, const OdGeVector3d& minorAxis, double majorRadius, double minorRadius) — Creates an elliptical arc with specified center, major axis, minor axis, major radius, and minorRadius.
  • OdGeEllipArc3d::OdGeEllipArc3d(const OdGePoint3d& center, const OdGeVector3d& majorAxis, const OdGeVector3d& minorAxis, double majorRadius, double minorRadius, double startAng, double endAng) — Creates an elliptical arc with specified center, major axis, minor axis, major radius, minorRadius, start and end angles.

The OdGeEllipArc3d class provides a set of methods for working with elliptical arc objects.

The center(), majorAxis(), minorAxis(), majorRadius(), minorRadius(), startAng(), endAng(), startPoint(), endPoint(), and normal() methods are used to obtain the center, axes, radiuses, end and start angles, end and start points, and normal vector respectively.

To set arc properties, use the corresponding methods: setCenter(), setMajorRadius(), setMinorRadius(), setAngles(), setAxes(), or one of the set() methods. For example:

OdGeEllipArc3d elArc1;
elArc1.set(OdGePoint3d(0,0,0), OdGeVector3d(1,0,0), OdGeVector3d(0,1,0), 2, 1);
elArc1.setAngles(OdaPI/4, 3*OdaPI/4);
OdGePoint3d p1 = elArc1.center();
OdGePoint3d p2 = elArc1.startPoint();
OdGePoint3d p3 = elArc1.endPoint();
OdGeVector3d v1 = elArc1.normal();

Radii of arcs must be positive. Therefore, user cannot create an arc with negative radii. However, arcs with non-orthogonal axes can be created. Code example and arcs with orthogonal axes (yellow) and with non- orthogonal axes (blue) are illustrated below:

Source code example orthogonal and non-orthogonal arcs:


OdGePoint3d origin1(0, 0, 0), origin2(50, 0, 0);
OdGeVector3d majorAxis1(1, 0.3, 0), minorAxis1(0, 1, 0),
             majorAxis2(1, 0, 0),   minorAxis2(0, 1, 0);

OdGeEllipArc3d arcsNonOrtho(origin1, majorAxis1, minorAxis1, 10, 5, 0, 4);
OdGeEllipArc3d arcsOrtho(origin2, majorAxis2, minorAxis2, 10, 5, 0, 4);

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.

For 3D elliptical 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 direction of the arc to change 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 isClockWise() method, which returns true if the arc has clockwise orientation.

The isInside() methods determine whether the specified point lies inside the full ellipse of this arc, and is on the same plane as this ellipse:

bool isInside = elArc1.isInside(p1);

The intersectWith() method defines whether the arc intersects the specified plane or line entities and calculates the number and coordinates of intersection points:

bool isIntersected;
isIntersected = elArc1.intersectWith(plane, numInt, p1, p2);
isIntersected = elArc1.intersectWith(ray, numInt, p1, p2);

The following parameters are used:

  • numInt — The number of intersections.
  • p1, p2 — Coordinates of intersection points. p1 has meaning only if numInt > 0; p2 has meaning only if numInt > 1.

The isCircular() method checks whether the arc is circular, i.e. the major and minor radii of the ellipse are the same within the specified tolerance:

bool isCircular = elArc1.isCircular();

The tangentAt() method calculates the tangent vector at the point that corresponds to the specified parameter:

OdGeVector3d tangent = elArc1.tangentAt(0.5);

Reverse Parameters

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


...
OdGeEllipArc3d ellipArc3d;
ellipArc3d.setInterval(OdGeInterval(0., OdaPI2));
...

The created 3D elliptical arc has equal parameters and angles 0 .. Pi/2. The created elliptical 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:


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

After reversing arc's geometry is changed inside, changes are hidden. The reversed elliptical 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. Arc’s direction is now clockwise.

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

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

See Also

Working with Circular Arcs

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