明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2705|回复: 9

关于椭圆狐!青帮忙!

[复制链接]
发表于 2002-10-14 09:03:00 | 显示全部楼层 |阅读模式
我用LISP将椭圆弧删除,然后重画一个椭圆,利用BREAK将其打断,得到和删除的椭圆弧一样的椭圆弧,运行后发现有的椭圆弧可以再现,有的打断后不一致,坐标和角度的计算没问题,可能是打断命令起始角和终止角的问题,两个角度和椭圆弧的绘画顺序有关,我一直没有找到规律,望指点!
发表于 2002-10-14 21:53:00 | 显示全部楼层

如果我没有记错的话,是在拾取点的时候出了问题

两个打断点都是你拾取的,而并不一定在被打断实体上的,所以就会出现不精确的问题了。
 楼主| 发表于 2002-10-15 09:04:00 | 显示全部楼层

那如何才能精确地选取打断点呢!!!!!救命!

椭圆计算公式是:p(u)=(Cx+a*cos(u))*i+(Cy+a*sin(u))*j
还是:p(u)=(Cx+a*cos(u))*i+(Cy+b*sin(u))*j
到底是那一个?是用这个公式计算吗!
 楼主| 发表于 2002-10-15 09:27:00 | 显示全部楼层

椭圆弧的起始和终止角度是如何确定的!

 楼主| 发表于 2002-10-15 09:52:00 | 显示全部楼层

请各位大虾帮我测试以下代码!

(DEFUN C:CESHI()
   ;首先画一个椭圆弧
   (SETVAR "ELLIPSE" 1)      
   (SETQ LC (ENTGET(ENTLAST)))
   (PRINC LC)
   (PRINC)
   (SETQ X1 (CADR (ASSOC 10 LC)) Y1 (CADDR (ASSOC 10 LC)))
   (SETQ X2 (+ X1 (CADR (ASSOC 11 LC))) Y2 (+ Y1 (CADDR (ASSOC 11 LC))))
   (SETQ PT1 (LIST X1 Y1) PT2 (LIST X2 Y2))
   (SETQ DISX (DISTANCE PT1 PT2))       ;长轴长度的一半              
   (SETQ XYDIS (* DISX (CDR (ASSOC 40 LC))));短轴长度的一半
   ;计算椭圆弧起始点PSX PSY                     
   (SETQ PSX (- X1 (* DISX (COS (CDR (ASSOC 41 LC))))))
   (SETQ PSY (- Y1 (* XYDIS (SIN (CDR (ASSOC 41 LC))))))
   ;计算椭圆弧终止点PEX PEY
   (SETQ PEX (- X1 (* DISX (COS (CDR (ASSOC 42 LC))))))
   (SETQ PEY (- Y1 (* XYDIS (SIN (CDR (ASSOC 42 LC))))))
   (SETQ PT3 (LIST PSX PSY) PT4 (LIST PEX PEY))
   (COMMAND "ERASE" "L" "")
   (COMMAND "ELLIPSE" "C" PT1 PT2 XYDIS)
   (COMMAND "BREAK" "L" PT4 PT3)
   (COMMAND "EXPLODE" "L" "")
   (SETVAR "ELLIPSE" 0)   
)
发表于 2002-10-15 10:00:00 | 显示全部楼层

椭圆弧的角度

在椭圆弧的定义过程中,怎样确定起始角度呢?在绘制椭圆弧时,首先要定义该弧所属的椭圆,然后指定它的起始角度。关键在于系统是把椭圆长轴的第一个端点看作为零度位置的。椭圆定义的方法不同,就有不同的起始角度值。可打开极轴功能,这时出现的极轴提示会帮助我们判断怎么确定角度。起始角到终止角也要按逆时针确定(除了你为系统定义了顺时针坐标体系)。
 楼主| 发表于 2002-10-15 11:42:00 | 显示全部楼层

谢谢东哥我去试一下

发表于 2002-10-15 12:15:00 | 显示全部楼层

没找到很智能的办法,用捕捉吧

发表于 2002-10-15 13:42:00 | 显示全部楼层

椭圆弧组码41的意义...

(defun C:EEE (/ A B N XX YY PT)
  (setq A 50.0);長軸
  (setq B 25.0);短軸
  (setq N 0.0)
  (repeat 360
    (setq XX (* A (cos (/ (* N pi) 180.0))))
    (setq YY (* B (sin (/ (* N pi) 180.0))))
    (setq PT (list XX YY))
    (COMMAND "_.POINT" PT)
    (setq N (1+ N))
  )
)
;;;p(u)=(Cx+a*cos(u))*i+(Cy+b*sin(u))*j


轉貼自XDRX:

;|椭圆弧组码41的意义...
In elliptical arcs, group code 41 is described as the start parameter. However,
it doesn't seem to be associated with any of the known values for the arc. How
is this value derived?
Answer
An elliptical arc is a special version of an arc that follows the eccentricity
of the ellipse. One way to generate this type of arc is to find the parametric
normal of the starting point. To do so, you must specify a start angle that is
different from the actual start angle of the drawn arc. Group code 41 contains
this parametric angle expressed in radians.

WHAT IS THE PARAMETRIC ANGLE?

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

HOW DO I CALCULATE IT FROM THE TRUE START ANGLE?

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

The following is an AutoLisp example that demonstrates how to use trigonometric
functions to determine the parametric angle:
code: |;
(defun C:E_ARC (/ A B SLOPE ANG Q1 Q2 Q3 Q4 QMODE X Y A2)
  ;;assuming 0,0 is at the center of the ellipse, major axis in x direction
  (setq ANG (getangle '(0.0 0.0) "Choose start angle: "))
  (setq        A     1
        B     0.5
        SLOPE (/ (sin ANG) (cos ANG))
        Q1    (/ pi 2.0)
        Q2    pi
        Q3    (/ (* 3 pi) 2.0)
        Q4    (* 2.0 pi)
        QMODE 'Q1
  )                                        ;setq
  (entmake (setq ENT '((0 . "ELLIPSE")
                       (100 . "AcDbEntity")
                       (100 . "AcDbEllipse")
                       (10 0.0 0.0 0.0)
                       (11 1.0 0.0 0.0)
                       (40 . 0.5)
                       (62 . 1)
                      )
           )                                ;setq
  )                                        ;entmake

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

  (setq        Y (/ (* A B SLOPE)
             (sqrt (+ (* (* SLOPE SLOPE) (* A A)) (* B B)))
          )
  )                                        ;setq

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

  ;;calculate start angle trigonometrically
  (setq        COS_A2 (/ X B)
        SIN_A2 (/ Y B)
  )                                        ;setq
  (if (/= COS_A2 0)
    (setq A2 (atan (/ SIN_A2 COS_A2)))
    (setq A2 Q1
          QMODE        'Q1
    )
  )                                        ;if


  ;;make a2 insensitive to quadrant
  (cond        ((and (> ANG Q1) (< ANG Q2))
         (setq A2    (- pi (abs A2))
               QMODE 'Q2
         )                                ;setq
        )                                ;statement 1
        ((and (> ANG Q2) (< ANG Q3))
         (setq A2    (+ (abs A2) pi)
               QMODE 'Q3
         )                                ;setq
        )                                ;statement 2
        ((and (> ANG Q3) (< ANG Q4))
         (setq A2    (abs (- (* 2 pi) (abs A2)))
               QMODE 'Q4
         )                                ;setq
        )                                ;statement 3

        ;;special cases: angle = 0, 90, 180, 270 or 360 deg
        ((or (= ANG 0) (= ANG Q1))
         (setq QMODE 'Q1)
        )                                ;statement 4
        ((= ANG Q2)
         (setq A2 pi
               QMODE 'Q1
         )
        )                                ;statement 5
        ((= ANG Q3)
         (setq A2    (- (/ pi 2.0) pi)
               QMODE 'Q1
         )
        )                                ;statement 6
        (t NIL)                                ;default statement
  )                                        ;cond

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

  (setq        A2
         (cond ((= QMODE 'Q1) A2)
               ((= QMODE 'Q2) A2)
               ((= QMODE 'Q3) (- A2 Q4))
               ((= QMODE 'Q4) (- A2 Q4))
               (t NIL)
         )                                ;cond
  )                                        ;setq

  (princ "\nParametric angle in radians: ")
  (princ A2)
  (princ "\nParametric angle in degrees: ")
  (princ (/ (* 180 A2) pi))
  (princ)

)                                        ;e_arc
发表于 2002-10-16 07:58:00 | 显示全部楼层

程序中起始和终止角度轉換錯誤!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 19:46 , Processed in 0.207288 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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