Jump to content

[Discussion] AutoCAD Curve gemetry - Calculating an average slope


Recommended Posts

Posted (edited)

I'd like to take an AutoCAD curve (polyline) & calculate the aproximate overall average slope of it. Attached is my code so far which works

 

(defun weightedAverageSlopeOfCurve (<obj>)
 
 ;Some function variables  
 (setq chainage 0.0 interval 0.1 tempList nil orig (list 0 0 0 ) maxIterations (fix 1e5) average 0.0)

 (setq startChainage (vlax-curve-getDistAtParam <obj> (vlax-curve-getStartParam <obj>))
endChainage  (vlax-curve-getDistAtParam <obj> (vlax-curve-getEndParam <obj>))
)

 ;Define the length of the curve
 
 (setq curveLength (-  endChainage startChainage  )
chainage  startChainage)

 ;Caclulate the number of iterations
 
 (setq iterations (fix (/ curveLength interval)))

;;Take some loading off the CPU if too many iterations required. Revert to maxIterations 
 (if
   (> iterations maxIterations)
   (setq interval (/ curveLength maxIterations) iterations maxIterations)

   )

 (repeat iterations

   (setq dy/dx (vlax-curve-getFirstDeriv <obj> (vlax-curve-getParamAtDist <obj> chainage))
  slope (angle orig dy/dx))

   (setq average (+ average (/ slope iterations)))

   (setq chainage (+ chainage interval))
   
   )
 average
 )

 

 

 

Has anybody any thoughts on the methodology or suggestions for a different approach?

Edited by jammie
Posted
your question is to vauge what is an average slope ? post example

 

Hi BIGAL,

 

Sorry for not getting back to this sooner. I'll try and be a little clearer, average slope probably was the wrong term to use.

 

 

Taking an AutoCAD curve, in this case a polyline, I am intereseted in determining the average vector travelled going from the start point to the end point of the polyine.

 

My original thinking was to break the curve down into a series of segments, calculate the slope at each segment & from that calculate an overall average slope / vector travelled

 

Regards

 

Jammie

Posted

Wont the average of a arc just be the tangential slope at the mid point ?

Posted

Or even the line joining the start point to the end point :unsure:

 

However the vectors vary along the way, they start at the start point and they arrive at the endpoint.

Posted

@BIGAL I hadn't considered that. I'll have to do a bit of testing to see how if/how I can incorporate this.

 

@eldon That was my thinking with vectors varing along the length of the curve. Every segment of the curve has a weighting on the overall average of the curve.

 

Perhaps the following could work?

 


1.    Determine the number of curve segements  			(n)
2.    Find the tangent @ each mid segment         		(m)
3.    Find length of that segment              			(l)
4.    Determine the magnitude of the vector (l*m) 		(s) 
5.    Add all the results & divide by total length of curve

 

Thanks for the help so far

 

Jammie

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...