+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    Computer Details
    jammie's Computer Details
    Operating System:
    Ubuntu / XP / W8
    Discipline
    Civil
    jammie's Discipline Details
    Occupation
    Design Technician
    Discipline
    Civil
    Using
    AutoCAD 2012
    Join Date
    May 2006
    Location
    Ireland
    Posts
    299

    Default [Discussion] AutoCAD Curve geometry - Calculating an average slope

    Registered forum members do not see this ad.

    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

    Code:
    (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?
    Last edited by jammie; 15th Sep 2011 at 02:05 pm.

  2. #2
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    your question is to vauge what is an average slope ? post example
    A man who never made mistakes never made anything

  3. #3
    Senior Member
    Computer Details
    jammie's Computer Details
    Operating System:
    Ubuntu / XP / W8
    Discipline
    Civil
    jammie's Discipline Details
    Occupation
    Design Technician
    Discipline
    Civil
    Using
    AutoCAD 2012
    Join Date
    May 2006
    Location
    Ireland
    Posts
    299

    Default

    Quote Originally Posted by BIGAL View Post
    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

  4. #4
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Wont the average of a arc just be the tangential slope at the mid point ?
    A man who never made mistakes never made anything

  5. #5
    Forum Deity
    Using
    AutoCAD 2002
    Join Date
    Sep 2006
    Location
    East Sussex, U.K.
    Posts
    2,969

    Default

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

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

  6. #6
    Senior Member
    Computer Details
    jammie's Computer Details
    Operating System:
    Ubuntu / XP / W8
    Discipline
    Civil
    jammie's Discipline Details
    Occupation
    Design Technician
    Discipline
    Civil
    Using
    AutoCAD 2012
    Join Date
    May 2006
    Location
    Ireland
    Posts
    299

    Default

    Registered forum members do not see this ad.

    @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?

    Code:
    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

Similar Threads

  1. Angle/Slope of Tangent to a curve vb.net
    By russell84 in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 6th Mar 2009, 09:44 am
  2. Seattle AutoCAD Discussion at your place or over Coffee
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 8th Jul 2008, 04:50 am
  3. AutoCAD 2009 and AutoCAD LT Discussion Forums
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 26th Mar 2008, 11:30 pm

Bookmarks

Posting Permissions

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