Previous Document Next Document
Segment.GetCurvatureAt

Function GetCurvatureAt([Offset As Double = 0.5], [OffsetType As cdrSegmentOffsetType = cdrParamSegmentOffset]) As Double

Member of Segment

The GetCurvatureAt method returns a numerical value that indicates the curvature of a segment at a given point.

The curvature value is the inverse of the curvature radius and depends on the current document units.

Parameters
Description
Offset
Specifies the offset, in document units, of a point on a segment’s subpath.
This parameter is optional, and its default value is 0.5.
OffsetType
Specifies the type of offset
This parameter is optional, and its default value is cdrParamSegmentOffset (2).

The following code example draws a circle so that it touches the selected curve at the point that represents 25% of its length. This circle has the same curvature as the curve at this point; that is, it shows the curvature radius.

Sub Test() 
 Dim c As Double, r As Double 
 Dim x As Double, y As Double, pa As Double 
 Dim seg As Segment 
 Set seg = ActiveShape.Curve.Segments(1) 
 c = seg.GetCurvatureAt(0.25, cdrRelativeSegmentOffset) 
 If Abs(c) < 0.00001 Then 
  MsgBox "The segment is almost straight at this point", vbCritical 
  Exit Sub 
 End If 
 seg.GetPointPositionAt 0.25, cdrRelativeSegmentOffset, x, y 
 pa = seg.GetPerpendicularAt(0.25, cdrRelativeSegmentOffset) 
 pa = pa * 3.1415926 / 180 
 r = 1 / c 
 x = x + r * Cos(pa) 
 y = y + r * Sin(pa) 
 ActiveLayer.CreateEllipse2 x, y, r 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.