马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- (defun c:tt ()
- (if (and
- (setq e (car (xdrx_entsel "\n拾取SPLINE<退出>:" '((0 . "SPLINE")))))
- (setq dis (getreal "\n输入玄高距<退出>:"))
- (setq ge (xdge::constructor e))
- (setq ePa (xdrx_curve_getEndParam e))
- (setq pts (xdge::getpropertyvalue ge "getsamplepoints" 0.0 ePa dis))
- (setq pts1 (car pts)
- pas1 (cadr pts)
- )
- )
- (progn
- (xdrx_begin)
- (setq pts (XD::List:SnakePair pts1)
- pas (XD::List:SnakePair pas1)
- )
- (setq i 0
- garcl nil
- )
- (mapcar
- '(lambda (x)
- (setq pmid (xdge::getpropertyvalue ge "evalPoint" (/
- (apply
- '+
- (nth i pas)
- ) 2.0
- )
- )
- garc (xdge::constructor "kCircArc2d" (car x) pmid
- (cadr x)
- )
- garcl (cons garc garcl)
- i (1+ i)
- )
- )
- pts
- )
- (xdge::entity:make (xdge::constructor "kCompositeCrv2d"
- (reverse garcl)
- )
- )
- (xdrx_entity_setcolor (entlast) 1)
- ;;下面代码是测试性能,可以删除
- (setq area1 (xdrx_getpropertyvalue e "area")
- area2 (xdrx_getpropertyvalue (entlast) "area")
- )
- (xdrx_object_regen (entlast))
- (apply 'xdrx_polyline_make pts1)
- (xdrx_entity_setcolor (entlast) 2)
- (princ (strcat "\n原始面积:" (rtos area1 2 3) ".\n圆弧模拟面积:"
- (rtos area2 2 3) ".误差:" (rtos (* 100 (/
- (abs
- (- area2 area1)
- ) area1
- )
- ) 2 5
- ) "%" "\n折线模拟面积:"
- (rtos (setq area3 (abs (apply
- 'xdrx_points_area
- pts1
- )
- )
- )
- 2 3
- ) ".误差:" (rtos (* 100 (/ (abs (- area3 area1)) area1))
- 2 5
- ) "%"
- )
- )
- ;;;;
- (xdrx_end)
- )
- )
- (princ)
- )
玄高距离100的时候的截图
玄高距100时候误差
拾取SPLINE<退出>:
输入玄高距<退出>:100
原始面积:74956697.475.
圆弧模拟面积:74958827.643.误差:0.00284%
折线模拟面积:74019558.882.误差:1.25024%
玄高距50时候误差,就不用截图了,因为红色的圆弧线基本和SPLINE重合了。
拾取SPLINE<退出>:
输入玄高距<退出>:50
原始面积:74956697.475.
圆弧模拟面积:74956363.920.误差:0.00044%
折线模拟面积:74481141.091.误差:0.63444%
|