ArcLength example

ArcLength returns the length in world-coordinate units along the specified curve. This function takes two parameters of type GCoordinate to represent parameter values between 0 and 1, where 0 represents the first point in the curve and 1 represents the last. The following code fragments find the length of the entire curve shown in Figure 49, and the length of a portion of the curve.


This code fragment gets the length for the entire curve because the curve parameter range is 0 to 1.

      TGCurve cubicCurve( TGPoint( 25, 125 ), 
                          TGPoint( 45, 200 ),
                          TGPoint( 95, 175 ),
                          TGPoint( 70, 150 ) );
      
      GCoordinate length;
      
      length = cubicCurve.ArcLength( 0, 1 );
      qprintf( "Arc length between 0 and 1 is %f\n", length );
The following text string is printed at the command line:

    Arc length between 0 and 1 is 102.184857
This code fragment gets the portion of the curve that lies between the points defined by parameters .25 and .75 of the curve. Figure 50 shows which portion of the curve this is.

      length = cubicCurve.ArcLength( .25, .75 );
      qprintf( "Arc length between .25 and .75 is %f\n", length );
      
      thePort.Draw( cubicCurve );
The following text string is printed at the command line:

    Arc length between 0 and 1 is 39.111765

[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