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.
The following code fragment creates the arc shown in Figure 54. TGArcThrough3Points( const TGPoint& p0,
const TGPoint& p1,
const TGPoint& p2 );
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( const TGPointArray& points, tension = 1.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 );
otherArc set to False
(the default)
otherArc set to True
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.
The following code fragment creates the arc shown in Figure 58. TGHermiteSpline( const TGPointArray& points );
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( const TGPointArray& points, GCoordinate tension, GCoordinate bias );
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 );