明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1192|回复: 1

请教请教请教:边界问题

[复制链接]
发表于 2004-1-6 17:16:00 | 显示全部楼层 |阅读模式
形成填充边界的时候,在boundary path data中获得Ellipse edge data group codes 中的50  Start angle 、 51 End angle 数值。用entmake 生成Elliptic arc 时如何把上面的50、51的信息转换成41、42呢?
我看了帮助的公式,可是结果还是不对。P(Theta) = A * cos(Theta) + B * sin(Theta)
where A and B are the semimajor and -minor axes respectively

我的程序如下:
(defun h-ellipse ()
  (setq        elhead
         '((0 . "ELLIPSE") (100 . "AcDbEntity") (100 . "AcDbEllipse"))
  )
  (setq edata (member (assoc 10 (cdr edata)) edata))
  (setq value50 (cdr (assoc 50 edata)))
  (setq value51 (cdr (assoc 51 edata)))
  (setq value73 (cdr (assoc 73 edata)))
  (setq        ed-10 (assoc 10 edata)
        ed-11 (assoc 11 edata)
        ed-40 (assoc 40 edata)
  )
  (setq a (/ (distance (list 0 0 0) (cdr ed-11)) 2)) ;求长半轴
  (setq b (* a (cdr ed-40)))                ;求短半轴
  (if (= value73 0)    ;判断逆时针
    (setq value50_1 (- 0 value51)
          value51  (- 0 value50)
          value50  value50_1
    )
  )
  (setq value41 (+ (* a (cos value50)) (* b (sin value50))))
  (setq value42 (+ (* a (cos value51)) (* b (sin value51))))
  (setq        ed-41 (cons 41 value41)
        ed-42 (cons 42 value42)
  )
  (setq edlist (list ed-10 ed-11 ed-40 ed-41 ed-42))
  (setq ednew (append elhead edlist))
  (entmake ednew)
  (ssadd (entlast) ssother)
)

请问有无AutoCAD 2002 的Express 工具安装程序下载?很多安装程序我用“完全安装”都没有。
发表于 2004-1-8 11:14:00 | 显示全部楼层

  1. ;;轉貼
  2. ;|橢圓弧組碼41的意義...
  3. In elliptical arcs, group code 41 is described as the start parameter. However,
  4. it doesn't seem to be associated with any of the known values for the arc. How
  5. is this value derived?
  6. Answer
  7. An elliptical arc is a special version of an arc that follows the eccentricity
  8. of the ellipse. One way to generate this type of arc is to find the parametric
  9. normal of the starting point. To do so, you must specify a start angle that is
  10. different from the actual start angle of the drawn arc. Group code 41 contains
  11. this parametric angle expressed in radians.

  12. WHAT IS THE PARAMETRIC ANGLE?

  13. The parametric angle is generated from two concentric circles whose center is
  14. the center of the ellipse and whose radii are the major and minor axes,
  15. respectively. Every point of the ellipse lies either between or on these two
  16. circles, and each elliptical point can be defined by a unique relation to them.
  17. To discover this relationship, draw a line perpendicular to the major axis from
  18. a point on the ellipse to the closest intersection with the circle described by
  19. the major axis. Then do the same with the minor axis, starting from the
  20. elliptical point and drawing perpendicular to the minor axis until the line
  21. intersects the circle described by the minor axis. The two points of
  22. intersection with the circles are colinear with the center of the ellipse. The
  23. angle between the line containing these three points and the major axis is the
  24. parametric angle specified by group code 41.

  25. HOW DO I CALCULATE IT FROM THE TRUE START ANGLE?

  26. To calculate the parametric angle from the true start angle, you must first find
  27. the start point on the ellipse. This requires a simultaneous solution to the
  28. equations for the line and the ellipse. In this example we assume that the major
  29. axis of the ellipse lies on the x-axis with the origin at the center of the
  30. ellipse. When this point is found, you can use its y-value and the minor axis to
  31. solve the equation for the circle whose radius is the minor axis value and whose
  32. center is the center of the ellipse. This will provide the x,y point on the
  33. circle that dictates the parametric angle from the center of the ellipse.

  34. The following is an AutoLisp example that demonstrates how to use trigonometric
  35. functions to determine the parametric angle:
  36. code: |;
  37. (defun C:E_ARC (/ A B SLOPE ANG Q1 Q2 Q3 Q4 QMODE X Y A2)
  38.   ;;assuming 0,0 is at the center of the ellipse, major axis in x direction
  39.   (setq ANG (getangle '(0.0 0.0) "Choose start angle: "))
  40.   (setq        A     1
  41.         B     0.5
  42.         SLOPE (/ (sin ANG) (cos ANG))
  43.         Q1    (/ pi 2.0)
  44.         Q2    pi
  45.         Q3    (/ (* 3 pi) 2.0)
  46.         Q4    (* 2.0 pi)
  47.         QMODE 'Q1
  48.   )                                        ;setq
  49.   (entmake (setq ENT '((0 . "ELLIPSE")
  50.                        (100 . "AcDbEntity")
  51.                        (100 . "AcDbEllipse")
  52.                        (10 0.0 0.0 0.0)
  53.                        (11 1.0 0.0 0.0)
  54.                        (40 . 0.5)
  55.                        (62 . 1)
  56.                       )
  57.            )                                ;setq
  58.   )                                        ;entmake

  59.   ;;line equation is y = mx + 0, where m is the slope and 0 is the y-intercept
  60.   ;;ellipse equation is x^2/a^2 + y^2/b^2 = 1
  61.   ;;solve line and ellipse equations simultaneously to find x and y values

  62.   (setq        Y (/ (* A B SLOPE)
  63.              (sqrt (+ (* (* SLOPE SLOPE) (* A A)) (* B B)))
  64.           )
  65.   )                                        ;setq

  66.   ;;minor axis circle equation is x^2 + y^2 = b^2
  67.   ;;solve circle equation where y = value calculated above
  68.   (setq X (sqrt (- (* B B) (* Y Y))))

  69.   ;;calculate start angle trigonometrically
  70.   (setq        COS_A2 (/ X B)
  71.         SIN_A2 (/ Y B)
  72.   )                                        ;setq
  73.   (if (/= COS_A2 0)
  74.     (setq A2 (atan (/ SIN_A2 COS_A2)))
  75.     (setq A2 Q1
  76.           QMODE        'Q1
  77.     )
  78.   )                                        ;if


  79.   ;;make a2 insensitive to quadrant
  80.   (cond        ((and (> ANG Q1) (< ANG Q2))
  81.          (setq A2    (- pi (abs A2))
  82.                QMODE 'Q2
  83.          )                                ;setq
  84.         )                                ;statement 1
  85.         ((and (> ANG Q2) (< ANG Q3))
  86.          (setq A2    (+ (abs A2) pi)
  87.                QMODE 'Q3
  88.          )                                ;setq
  89.         )                                ;statement 2
  90.         ((and (> ANG Q3) (< ANG Q4))
  91.          (setq A2    (abs (- (* 2 pi) (abs A2)))
  92.                QMODE 'Q4
  93.          )                                ;setq
  94.         )                                ;statement 3

  95.         ;;special cases: angle = 0, 90, 180, 270 or 360 deg
  96.         ((or (= ANG 0) (= ANG Q1))
  97.          (setq QMODE 'Q1)
  98.         )                                ;statement 4
  99.         ((= ANG Q2)
  100.          (setq A2 pi
  101.                QMODE 'Q1
  102.          )
  103.         )                                ;statement 5
  104.         ((= ANG Q3)
  105.          (setq A2    (- (/ pi 2.0) pi)
  106.                QMODE 'Q1
  107.          )
  108.         )                                ;statement 6
  109.         (t NIL)                                ;default statement
  110.   )                                        ;cond

  111.   (command "zoom" "c" "0,0" 3)
  112.   (setq
  113.     ENT        (append ENT (list (cons 41 A2) (cons 42 (+ A2 (/ pi 2.0)))))
  114.   )
  115.   (setq ENT (subst '(62 . 5) (assoc 62 ENT) ENT))
  116.   (entmake ENT)

  117.   (setq        A2
  118.          (cond ((= QMODE 'Q1) A2)
  119.                ((= QMODE 'Q2) A2)
  120.                ((= QMODE 'Q3) (- A2 Q4))
  121.                ((= QMODE 'Q4) (- A2 Q4))
  122.                (t NIL)
  123.          )                                ;cond
  124.   )                                        ;setq

  125.   (princ "\nParametric angle in radians: ")
  126.   (princ A2)
  127.   (princ "\nParametric angle in degrees: ")
  128.   (princ (/ (* 180 A2) pi))
  129.   (princ)

  130. )                                        ;e_arc
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-2 03:24 , Processed in 0.179172 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表