Previous Document Next Document
SubPath.GetCurvatureAt

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

Member of SubPath

The GetCurvatureAt method returns the curvature of a subpath at a given point.

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

Parameters
Description
Offset
Specifies the offset, in document units
This parameter is optional, and its default value is 0.5.
OffsetType
Specifies the type of offset of a subpath. This parameter returns cdrSegmentOffsetType.
This parameter is optional, and its default value is cdrRelativeSegmentOffset (1).

The following code example draws a circle that touches the selected curve at the point that is 25% of the length of its first subpath, and that has the same curvature as the curve in this point (thereby showing the curvature radius):

Sub Test() 
 Dim c As Double, r As Double 
 Dim x As Double, y As Double, pa As Double 
 Dim sp As SubPath 
 Set sp = ActiveShape.Curve.Subpaths(1) 
 c = sp.GetCurvatureAt(0.25, cdrRelativeSegmentOffset) 
 If Abs(c) < 0.00001 Then 
  MsgBox "The curve is almost straight at this point", vbCritical 
  Exit Sub 
 End If 
 sp.GetPointPositionAt 0.25, cdrRelativeSegmentOffset, x, y 
 pa = sp.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.