Previous Document Next Document

Object Model Reference : Classes : S : Segment : Methods : Segment.GetTangentAt


Segment.GetTangentAt

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

Description

Member of Segment

The GetTangentAt method returns the angle of the tangent at a specified point on a curve segment.

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

VBA example

The following VBA example draws perpendicular and tangent vectors for several points uniformly distributed along the segments of the selected curve.

Sub Test()
Dim seg As Segment
Dim t As Double
For Each seg In ActiveShape.Curve.Segments
For t = 0 To 10 Step 2
MarkPoint seg, t / 10
Next t
Next seg
End Sub
Private Sub MarkPoint(seg As Segment, t As Double)
Dim x As Double, y As Double
Dim dx As Double, dy As Double
Dim a1 As Double, a2 As Double
seg.GetPointPositionAt x, y, t, cdrRelativeSegmentOffset
a1 = seg.GetTangentAt(t, cdrRelativeSegmentOffset) ' * 3.1415926 / 180
a2 = seg.GetPerpendicularAt(t, cdrRelativeSegmentOffset) * 3.1415926 / 180
dx = 0.5 * Cos(a1)
dy = 0.5 * Sin(a1)
With ActiveLayer.CreateLineSegment(x, y, x + dx, y + dy)
.Outline.EndArrow = ArrowHeads(1)
End With
dx = 0.5 * Cos(a2)
dy = 0.5 * Sin(a2)
With ActiveLayer.CreateLineSegment(x, y, x + dx, y + dy)
.Outline.EndArrow = ArrowHeads(1)
End With
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.