    # Thread: vlax routine perpendicular lines along polyline.

1. Login to Give a bone

## Re: vlax routine perpendicular lines along polyline. Originally Posted by richards.64879
WARNING: vlax-curve-getSecondDeriv returns 0 for lines and line segments.
Yes, that is good, otherwise you can not separate lines from arcs in a polyline.

: ) Happy Computing !

kennet  Reply With Quote

2. Login to Give a bone

## Re: vlax routine perpendicular lines along polyline.

To the library . . .

Imagine that a polyline is a path after a running ball,
so the polyline represents the position, point by point of the ball over time,
the first derivative would be the speed at any particular point in time,
vlax-curve-getFirstDeriv returns it as a simply local coordinate
and the speed-direction vector start local at (0.0 0.0 0.0).

The second derivative is another directional vector,
it shows how a force turn the ball to the left or right to make it follow the polyline.
This force-direction vector is perpendicular to the CURVE and it is NEVER (0.0 0.0 0.0).
vlax-curve-getSecondDeriv returns it as a simply local coordinate
and the force-direction vector start local at (0.0 0.0 0.0).

With straight segments the direction is never changing to the left or right,
so the second derivative of a LINE segment is ALWAYS (0.0 0.0 0.0).

Code:
```Example:
(setq Ent (entsel "Select the polyline curve : " ) )
(setq VlaObj (vlax-ename->vla-object (car Ent )) )
(setq Pt (getpoint "Pick a point on the polyline curve : " ) )
(setq Param (vlax-curve-getParamAtPoint VlaObj Pt ) )
(setq AngDeg (* (/ (angle (vlax-curve-getFirstDeriv  VlaObj Param ) '(0.0 0.0 0.0)) pi ) 180 ) ) ; Direction from Pt
(setq AngDeg (* (/ (angle (vlax-curve-getSecondDeriv VlaObj Param ) '(0.0 0.0 0.0)) pi ) 180 ) ) ; Perpendicular to Pt

(equal (vlax-curve-getSecondDeriv VlaObj Param ) '(0.0 0.0 0.0) ) ; = Line segment
(not (equal (vlax-curve-getSecondDeriv VlaObj Param ) '(0.0 0.0 0.0)) ) ; = Curve segment```
: ) Happy Computing !

kennet  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•