找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1194|回复: 0

[ADN开发资料]:椭圆弧组码41的意义...

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-19 11:53:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Explanation of elliptical arcs group code 41  
ID    467  
Applies to:    AutoCAD

Date    6/22/2000  

This document is part of    Visual Lisp   DXF Issues   Ellipse   Group Codes     


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

  1. [FONT=courier new]
  2. (defun c:e_arc( / a b slope ang q1 q2 q3 q4 qmode x y a2)
  3. ;assuming 0,0 is at the center of the ellipse, major axis in x direction
  4.         (setq ang (getangle '(0.0 0.0) "Choose start angle: "))
  5.         (setq a 1
  6.                 b 0.5
  7.                 slope (/ (sin ang) (cos ang))
  8.                 q1 (/ pi 2.0)
  9.                 q2 pi
  10.                 q3 (/ (* 3 pi) 2.0)
  11.                 q4 (* 2.0 pi)
  12.                 qmode 'q1
  13.         );setq
  14.         (entmake (setq ent '((0 . "ELLIPSE")
  15.                         (100 . "AcDbEntity")
  16.                         (100 . "AcDbEllipse")
  17.                         (10 0.0 0.0 0.0)
  18.                         (11 1.0 0.0 0.0)
  19.                         (40 . 0.5)
  20.                         (62 . 1))
  21.                 );setq
  22.         );entmake

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

  26.         (setq y (/ (* a b slope) (sqrt (+ (* (* slope slope) (* a a)) (* b b))))
  27.         );setq

  28. ;minor axis circle equation is x^2 + y^2 = b^2
  29. ;solve circle equation where y = value calculated above
  30.         (setq x (sqrt (- (* b b) (* y y))))

  31. ;calculate start angle trigonometrically
  32.         (setq cos_a2 (/ x b)
  33.               sin_a2 (/ y b)
  34.         );setq
  35.         (if (/= cos_a2 0)
  36.                 (setq a2 (atan (/ sin_a2 cos_a2)))
  37.                 (setq a2 q1 qmode 'q1)                         
  38.         );if


  39. ;make a2 insensitive to quadrant
  40.         (cond ((and (> ang q1) (< ang q2))
  41.                                 (setq a2 (- pi (abs a2)) qmode 'q2
  42.                                 );setq
  43.                         );statement 1
  44.                         ((and (> ang q2) (< ang q3))
  45.                                 (setq a2 (+ (abs a2) pi) qmode 'q3
  46.                                 );setq
  47.                         );statement 2
  48.                         ((and (> ang q3) (< ang q4))
  49.                                 (setq a2 (abs (- (* 2 pi) (abs a2))) qmode 'q4
  50.                                 );setq
  51.                         );statement 3

  52.         ;special cases: angle = 0, 90, 180, 270 or 360 deg
  53.                         ((or (= ang 0) (= ang q1))
  54.                                 (setq qmode 'q1)
  55.                         );statement 4
  56.                         ((= ang q2)
  57.                                 (setq a2 pi qmode 'q1)
  58.                         );statement 5
  59.                         ((= ang q3)
  60.                                 (setq a2 (- (/ pi 2.0) pi) qmode 'q1)
  61.                         );statement 6
  62.                         (t nil);default statement
  63.         );cond

  64.         (command "zoom" "c" "0,0" 3)               
  65.         (setq ent (append  ent (list (cons 41 a2) (cons 42 (+ a2 (/ pi 2.0))))))
  66.         (setq ent (subst '(62 . 5) (assoc 62 ent) ent))
  67.         (entmake ent)
  68.        
  69.         (setq a2
  70.                 (cond ((= qmode 'q1) a2)
  71.                         ((= qmode 'q2) a2)
  72.                         ((= qmode 'q3) (- a2 q4))
  73.                         ((= qmode 'q4) (- a2 q4))
  74.                         (t nil)
  75.                 );cond
  76.         );setq
  77.        
  78.         (princ "\nParametric angle in radians: ")
  79.         (princ a2)
  80.         (princ "\nParametric angle in degrees: ")
  81.         (princ (/ (* 180 a2) pi))
  82.         (princ)
  83.        
  84. );e_arc[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 02:24 , Processed in 0.172690 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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