Conic curve classes

TGCurve has the derived classes shown in Figure 48 that you can use to instantiate a TGCurve. These classes serve to clarify different types of arcs that have similar arguments. Do not instantiate these classes independently; use them in TGCurve constructors only. The following sections describe these classes, show their constructors, and provide examples.

NOTE TGCurve3D has corresponding conic curve derived classes. The examples here are the same as for creating their 3-D counterparts except for the additional z coordinate needed for 3-D geometries.


TGArcThrough3Points

This class creates an arc that passes through three points.

      TGArcThrough3Points(    const TGPoint& p0,
                              const TGPoint& p1,
                              const TGPoint& p2 );
The following code fragment creates the arc shown in Figure 54.


      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGCurve arcCurve = TGArcThrough3Points(     TGPoint( 10, 25 ), 
                                                  TGPoint( 50, 30 ), 
                                                  TGPoint( 100, 75 ) );
      thePort.Draw( arcCurve, frameBundle );

TGCardinalSpline

This class creates and fits a parametric curve to the set of control points passed to it in the array. The fit is accomplished by interpolating the middle two control points and finding the tangent at those points that is parallel to the line between the previous control point and the next control point. The tension parameter controls how tightly the curve interpolates the control polyline. The tension parameter values range from 0.0 to 1.0 where 0.0 is very tight and 1.0 is very loose. The number of points in the array must be a multiple of four.

      TGCardinalSpline( const TGPointArray& points, tension = 1.0 );
The following code fragments create the cardinal splines shown in Figure 55. The curve on the left has its tension parameter set to 1.0, and the curve on the right has its tension parameter set to 0.0.


Tension set to 1.0 (the default)

      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGPointArray aPointArray( 4 );
      
      aPointArray.SetPoint( TGPoint( 10, 25 ) );
      aPointArray.SetPoint( TGPoint( 50, 30) );
      aPointArray.SetPoint( TGPoint( 100, 75 ) );
      aPointArray.SetPoint( TGPoint( 125, 150) );
      
      TGCurve cardinalCurve = TGCardinalSpline( aPointArray )
      
      thePort.Draw( cardinalCurve, frameBundle );

Tesnsion set to 0.0

      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGPointArray aPointArray( 4 );
      
      aPointArray.SetPoint( TGPoint( 10, 25 ) );
      aPointArray.SetPoint( TGPoint( 50, 30) );
      aPointArray.SetPoint( TGPoint( 100, 75 ) );
      aPointArray.SetPoint( TGPoint( 125, 150) );
      
      TGCurve cardinalCurve = TGCardinalSpline( aPointArray, 0.0 )
      
      thePort.Draw( cardinalCurve, frameBundle );

TGConicEndCenterEnd

This class creates a conic curve from a start point, endpoint, center point, and a Boolean value. The points create an elliptical shape like the one shown in Figure 48. The conic curve tangents are perpendicular to the vectors between p0 and centerPoint, and centerPoint and p2. When the vectors are equal, a circular arc is generated that is less than 180 degrees.

In Figure 48 the arc passes from p0 to p2 in a counterclockwise direction forming an elliptical shape with the centerPoint parameter at the center of the ellipse. When otherArc is set to False, the curve created by p0 to p2 in a counterclockwise direction is created. When otherArc is set to True, the curve formed by the ellipse minus the p0 to p2 arc is created.


      TGConicEndCenterEnd(    const TGPoint& p0,
                              const TGPoint& centerPoint,
                              const TGPoint& p2,
                              Boolean otherArc = FALSE );
The following code fragments create the conic curve shown in Figure 57. The curve on the left has the otherArc parameter set to False, and the curve on the right has its otherArc parameter set to True.


otherArc set to False (the default)

      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGCurve conicCurve = TGConicEndCenerEnd( 
    TGPoint( 10, 25 ), TGPoint( 50, 30 ), TGPoint( 100, 75 ) ); thePort.Draw( conicCurve, frameBundle );

otherArc set to True

      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGCurve conicCurve = TGConicEndCenerEnd(
    TGPoint( 10, 25 ), TGPoint( 50, 30 ), TGPoint( 100, 75 ), TRUE ); thePort.Draw( conicCurve, frameBundle );

TGHermiteSpline

This class generates a parametric spline by interpolating between the two end points pased to it in the array and their tangents. The number of points in the array must be a multiple of four.

      TGHermiteSpline( const TGPointArray& points );
The following code fragment creates the arc shown in Figure 58.


      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGPointArray aPointArray( 4 );
      
      aPointArray.SetPoint( TGPoint( 10, 25 ) );
      aPointArray.SetPoint( TGPoint( 50, 30) );
      aPointArray.SetPoint( TGPoint( 100, 75 ) );
      aPointArray.SetPoint( TGPoint( 125, 150) );
      
      TGCurve hermiteCurve = TGHermiteSpline( aPointArray )
      
      thePort.Draw( hermiteCurve, frameBundle );

TGTensionSpline

This class creates a parametric spline from an array of points that are interpolated by tension and bias values. The tension controls how close the curve is to the control polyline. The number of points in the array must be a multiple of four.

      TGTensionSpline( const TGPointArray& points, GCoordinate tension, GCoordinate bias );
The following code fragment creates the tension curve shown in Figure 59 on the far-left where the tension and bias are set to 1.0. This figure also shows the same curve with different tension and bias values as noted.


      TFrameBundle frameBundle( TRGBColor( 0, 0, 0 ), 5.0 );
      TGPointArray aPointArray( 4 );
      
      aPointArray.SetPoint( TGPoint( 10, 25 ) );
      aPointArray.SetPoint( TGPoint( 50, 30) );
      aPointArray.SetPoint( TGPoint( 100, 75 ) );
      aPointArray.SetPoint( TGPoint( 125, 150) );
      
      TGCurve tensionCurve = TGTensionSpline( aPointArray, 1.0, 1.0 )
      
      thePort.Draw( tensionCurve, frameBundle );


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker