【讨论】AutoCAD曲线宝石
我想取一条AutoCAD曲线(多段线)&计算其近似的总平均斜率。附件是到目前为止我的代码(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)
chainagestartChainage)
;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
)
有人对另一种方法的方法或建议有什么想法吗? 你的问题是,平均坡度是多少?post示例
嗨,比格尔,
很抱歉没能早点回来。我会尽量澄清一点,平均斜率可能是用错了词。
以一条AutoCAD曲线(本例中为多段线)为例,我感兴趣的是确定从多段线的起点到终点的平均矢量。
我最初的想法是将曲线分解为一系列段,计算每个段的坡度,然后计算出总平均坡度/矢量
当做
杰米 弧的平均值不是中点处的切斜率吗? 甚至是连接起点和终点的线
然而,向量会随着路径的变化而变化,它们从起点开始,然后到达终点。 @比加尔我没有考虑过。我必须做一点测试,看看我是否/如何能够将其合并。
@eldon这是我的想法,向量沿着曲线的长度变化。曲线的每一段都对曲线的总体平均值具有权重。
也许以下方法可行?
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
谢谢你的帮助
杰米
页:
[1]