Programming Challenge 6/22

Programming Challenge 6/22

john.uhden
Mentor Mentor
2,069 Views
47 Replies
Message 1 of 48

Programming Challenge 6/22

john.uhden
Mentor
Mentor

This one has my head spinning.

The challenge is to write a function that returns the point on an ellipse where the tangent direction is equal to the one entered.

The function shall take two (2) arguments:

1.  the ename of the ellipse

2.  the desired tangent angle in radians

No, you will not make your own ellipse, nor have your function select one, nor add any code to confirm that the entity is in fact an ellipse.  If you can't use what I give you below, then tell your boss (if you have one) and tell your family (if you have one) and tell your friend (if you have one) that you are taking a one-way trip to the Ukraine (or Chatsworth, NJ if you prefer).

I am ignorant of any direct way to find the point, so to me it will require iteration to converge on the solution.

You may use a fuzz of 1e-8, nothing larger.  @calderg1000 is the only one entitled to use a fuzz of zero.

This exercise is only for determining the point in space where Tommy Lee Jones must exit the space station to land on the moon.  It's not for like building a geometrically perfect playground or something.

The ellipse is defined as:

(setq ellipse
(entmakex
'((0 . "ELLIPSE")(100 . "AcDbEntity")(67 . 0)(410 . "Model")
(8 . "0")(100 . "AcDbEllipse")(10 36.0 5.0 0.0)(11 -2.0 1.5 0.0)
(210 0.0 0.0 1.0)(40 . 0.5)(41 . 0.0)(42 . 5.0))
)
)

The angle in radians = 5.8

I have no idea as yet what the solution is, nor may I ever find out except by trial and error, or if @LeeMinardi shows me with his vector voodoo.

John F. Uhden

0 Likes
2,070 Views
47 Replies
Replies (47)
Message 21 of 48

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

....

Where do "virtual" lines come into this?

....


I meant that in the sense that you were not looking for a Line [or Polyline or Ray or Xline] to be drawn, but only wanted the location on the Ellipse at which such an object, running in the designated direction, would be tangent to the Ellipse.  A place to put such an object, of whatever type you want, but not an actual drawn object.

 

The word "tangent" means "touching."  It has come to mean, in mathematical terms, touching in a particular way, but in my opinion, doing so in either direction still qualifies.  Nevertheless, my routine above satisfies your limitation on the meaning of it.

 

EDIT:  Further consideration:  By your definition, not one of these Circles, which were drawn with the Circle command's Tangent-Tangent-Radius option, is tangent to any other:

Kent1Cooper_1-1646939502997.png

a notion which I find downright ludicrous.

 

Kent Cooper, AIA
0 Likes
Message 22 of 48

john.uhden
Mentor
Mentor

@dbroad 

Your thinking is dead on, as usual.

If I wanted a "virtual" line I would have said so.

Had I mentioned the word "direction?"

John F. Uhden

0 Likes
Message 23 of 48

Kent1Cooper
Consultant
Consultant

@dbroad wrote:

I think John is looking for a vector, a ray tangent to the ellipse, not an xline.


[No, he's looking for a location on the Ellipse at which such a vector or ray would be tangent to it.]

Kent Cooper, AIA
0 Likes
Message 24 of 48

john.uhden
Mentor
Mentor

@Kent1Cooper 

Excuse me, but to quote myself, "... the point on an ellipse where the tangent direction is equal to the one entered."

I didn't say just tangent, which I agree with you can mean either direction.  In fact, just tangent has no singular direction; it's just a condition, OR

[Merriam - Webster]

: a small upright flat-ended metal pin at the inner end of a clavichord key that strikes the string to produce the tone
 
How do you program a clavichord key?  Maybe using ClaviLisp?

John F. Uhden

0 Likes
Message 25 of 48

dbroad
Mentor
Mentor

Try this.  Technically knowing which way the vector must point wasn't really covered so I could see two possible solutions on each  whole ellipse.

(defun tan  (ang)
  (if (zerop (cos ang))
    (/ (sin ang) 1e-308)
    (/ (sin ang) (cos ang))))

(defun groupby3	 (lst)
  (if (null lst)
    nil
    (cons (cons (car lst) (cons (cadr lst) (cons (caddr lst) nil)))
	  (groupby3 (cdddr lst)))))

;given ellipse ename and angle in radians, find points at which lines drawn in that direction would
;;be tangent to the ellipse
;;D. C. Broad, Jr.
;;Adjusted for 2d rotation and translation but not for 3d rotation.
;;Not tested for non-WCS state.
(defun ptonellipse  (ellipse ang / 2PI A ANG2 B CTR EO MAJAXIS MINAXIS MSP PHI PTLST PTS ROT THETA XLINE)
  (setq 2pi (* 2 pi))			;probably unecessary but keeping angles between 0 and 2pi
  (setq eo (vlax-ename->vla-object ellipse)) ;convert to object 
  (setq majaxis (vlax-get eo 'majoraxis))
  (setq rot (rem (angle '(0 0 0) majaxis) 2pi)) ;determine ellipse rotaton
  (setq ang2 (- ang rot))		;adjust ang by counter rotating.
  (setq phi (rem (+ ang2 2pi (/ pi 2)) 2pi)) ;perpendicular to ang2.
  (setq minaxis (vlax-get eo 'minoraxis))
  (setq ctr (vlax-get eo 'center))
  (setq a (distance '(0 0 0) majaxis)) ;semimajor axis length
  (setq b (distance '(0 0 0) minaxis)) ;semiminor axis length
  (setq theta (atan (* (tan (+ (/ pi 2) ang2)) (/ (* b b) (* a a))))) ;angle conversion (key)
  (setq msp (vla-get-modelspace (vla-get-document eo)))
  (setq	xline (vla-addxline
		msp
		(vlax-3d-point ctr)
		(vlax-3d-point (polar ctr (+ theta rot) 1)))
	pts   (vlax-invoke eo 'intersectwith xline acextendnone)
	ptlst (groupby3 pts))
  (vla-delete xline)
  (foreach n ptlst
    (vla-addpoint msp (vlax-3d-point n))
    )
  ptlst)
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 26 of 48

Sea-Haven
Mentor
Mentor

Hi Dbroad I think your right go back to 1st principles for a ellipse found another image.

SeaHaven_0-1646974391221.png

Taking this theory its easy to draw a tangent at a ellipse point, using normal Acad, line circle etc.

 

SeaHaven_1-1646974515689.png

Ok for the tricky bit given Johns task 

 

The ellipse above is 200x 100 lower left 0,0 for simplicity.

Dumpit reveals a lot more useful stuff than entget as 1st step.

 

; Center = (100.0 50.0 0.0)
; EndAngle = 6.28318530717959
; EndParameter = 6.28318530717959
; EndPoint (RO) = (0.0 50.0 0.0)
; EntityName (RO) = "AcDbEllipse"
; MajorAxis = (-100.0 0.0 0.0)
; MajorRadius = 100.0
; MinorAxis (RO) = (0.0 -50.0 0.0)
; MinorRadius = 50.0
; Normal = (0.0 0.0 1.0)
; RadiusRatio = 0.5
; StartAngle = 0.0

 

The rotated ellipse and a chunk missing rotated around 100,50 like Johns.

Center = (100.0 50.0 0.0)
; EndAngle = 5.41444906889887
; EndParameter = 5.11248640424141
; EndPoint (RO) = (89.2931875880689 109.356871670377 0.0)
; EntityName (RO) = "AcDbEllipse"
; HasExtensionDictionary (RO) = 0
; MajorAxis = (-86.6025403784439 50.0 0.0)
; MajorRadius = 100.0
; MinorAxis (RO) = (-25.0 -43.3012701892219 0.0)
; MinorRadius = 50.0
; Normal = (0.0 0.0 1.0)
; RadiusRatio = 0.5
; StartAngle = 0.0866080357023967
; StartParameter = 0.171935938283013
; StartPoint (RO) = (10.3971284385284 91.8543526740536 0.0)

 

Given major radius , minor radius, should be able to work out the focus pts, using intersectwith can get ang1 = pt-> focus1, ang2 = pt -> focus2 so 90 angle is (ang1 ang2) / 2 add 90 is it tangent angle, if yes solved for John. Just  need to work out from info center and angle of major axis. 

 

All this geometry has given me a thirst so will think some more whilst having a quite beer.

 

 

0 Likes
Message 27 of 48

dbroad
Mentor
Mentor
Accepted solution

When I first started coding, I assumed that the ellipse parameter was simply the internal angle theta as measured from the start direction.  I was wrong.  This code shows how the parameter is actually implemented.  That is why I had to use the xline at the angle theta and intersectwith in my previous post rather than simply using vlax-curve-getpointatparam.  It might be possible to code without using intersectwith though.   There are equations for the focus locations.

 

;;The relationship between points on an ellipse and the angle
;;parameter of the ellipse (ang) is defined by this function.
;;Per Autodesk help p(angle) = c + a*cos(angle)+b*sin(angle)
;;Note: The ang parameter is not the same as the internal angle theta
;;      and a and b are not simply scalar distances of the axes.
;;Coded by D. C. Broad, Jr.  3/11/2022
;;Args:  ellipse is an ename, ang is the angle parameter (not theta)
;;Note: ang is equal to theta at 0, pi/2, pi, 3pi/2 and for a full ellipse 2pi.
;;This function accepts ang parameters greater than the angle end paramter
;; and may return points off the actual elliptical arc.
(defun p (ellipse ang / a b c e ca sa)
  (setq e (vlax-ename->vla-object ellipse)
	a (vlax-get e 'MajorAxis)
	b (vlax-get e 'MinorAxis)
	c (vlax-get e 'Center)
        ca (cos ang)
        sa (sin ang)
   )
  (mapcar '+
	  c
	  (mapcar '(lambda (n)(* ca n)) a)
          (mapcar '(lambda (n)(* sa n)) b)
  )
)

 

The function above essentially returns the same result as vlax-curve-getpointatparam but the built-in function would error out if the param was beyong the endparam, as it should.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 28 of 48

_gile
Consultant
Consultant
Accepted solution

Hi,

This is certainly not the most efficient way, but it seems to work as expected.

The code uses a dichotomic search of the point according to the angle accuracy (hard coded).

 

 

(defun getPointAtTangent (ellipse tanAngle / wrapTo2Pi angbase param delta ang)
  (defun wrapTo2Pi (a)
    (cond
      ((< a 0) (wrapTo2Pi (+ a (* PI 2))))
      ((< (* PI 2) a) (rem a (* PI 2)))
      (T a)
    )
  )
  (setq	angbase	 (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv ellipse 0.))
	tanAngle (wrapTo2Pi (- tanAngle angbase))
	param	 0.
	delta	 (* 2. PI)
  )
  (while
    (not
      (equal (setq ang
		    (wrapTo2Pi
		      (- (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv ellipse param)) angbase)
		    )
	     )
	     tanAngle
	     1e-12			; <- angle accuracy
      )
    )
     (setq param (if (< (- tanAngle ang) 0.)
		   (- param (setq delta (* delta 0.5)))
		   (+ param (setq delta (* delta 0.5)))
		 )
     )
     (if (< param 0.)
       (setq param (+ param (* 2. PI)))
     )
  )
  (vlax-curve-getPointAtParam ellipse param)
)

A testing command:

 

(defun c:test (/ e a p)
  (if (and (setq e (car (entsel)))
	   (= (cdr (assoc 0 (entget e))) "ELLIPSE")
      )
    (while (setq a (getangle "\nTangent direction: "))
      (setq p (getPointAtTangent e a))
      (entmake (list (cons 0 "RAY")
		     (cons 100 "AcDbEntity")
		     (cons 100 "AcDbRay")
		     (cons 10 p)
		     (list 11 (cos a) (sin a) 0.0)
	       )
      )
    )
  )
  (princ)
)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 29 of 48

dbroad
Mentor
Mentor

The function I posted works but I wish I hadn't needed the xline and intersectwith. As I just posted, the problem I faced was that I could code the relationship between the central angle and the normal angle to the ellipse but the angle parameter wasn't equal to the central angle.  Therefore I couldn't directly use vlax-curve-getpointatparam.

 

This web page was helpful to me. The first answer shows the process.

https://math.stackexchange.com/questions/175191/normal-to-ellipse-and-angle-at-major-axis

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 30 of 48

john.uhden
Mentor
Mentor

@_gile 

I have no idea what dichotomic is, but your function works!

BUT

like mine, only if (210 0.0 0.0 1.0).

If (210 0.0 0.0 -1.0) then it just runs around in circles (or maybe ellipses).

John F. Uhden

0 Likes
Message 31 of 48

john.uhden
Mentor
Mentor

@dbroad 

That looks like very clever code, BUT

your solution does not match what @_gile and mine did.

It appears that your solution was at the maximum Y for the ellipse if closed.

John F. Uhden

0 Likes
Message 32 of 48

john.uhden
Mentor
Mentor

@dbroad 

It worked.  IT WORKED!

On both original and mirrored ellipses!

But by now I guess I am to blame for not making the angle definition completely clear.

I used the phrase "tangent direction" which some seem not to understand, obviously because the word "direction" has so many connotations.

I guess I should have used the phrase "first derivative angle" but the word "angle" has many connotations as well, like for instance fishing for a solution.

 

John F. Uhden

0 Likes
Message 33 of 48

dbroad
Mentor
Mentor

I think mine works on any ellipse or elliptical arc you want to throw at it. I am attaching test data for your original case using your function, gile's function, and mine, separated by layer for angles 5.8, 5, and pi.  I couldn't use Gile's test function since I couldn't answer pi to his getangle function.  When I first moved his xline function into his getPointAtTangent function his rays were weird directions until I notice that he was changing the tanangle direction in the program itself.  I fixed that. Note that yours and Gile's include a tangent off the ellipse, at the top, which I deliberately avoided by using intersectwith.  Mine also gives 2 solutions at 5 but only one solution at 5.8 since the tangent point is off the elliptical arc.  You could add logic if you only want a solution to go in the same direction as the first derivative. That could easily trim the point list.

 

Note that the test drawing uses radian angle units.

 

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 34 of 48

john.uhden
Mentor
Mentor

@dbroad 

Could you get your ptonellipse function to return just the tangent point whose first derivative angle is equal to the input angle?  I hope it simplifies the code.

John F. Uhden

0 Likes
Message 35 of 48

CodeDing
Advisor
Advisor

@john.uhden ,

 

This was really fun! I think I have a useable solution. My little brother (Drue) helped me with the hard math parts. He's a genius.

 

The main function (to pass ellipse and angle) are toward the bottom. The last function is a TEST command.

 

Given your original ellipse, my TEST command creates a Circle of one acceptable tangent point on the ellipse...

image.png

 

The general workflow is as follows:

- Ellipse and Angle passed to main function
- Pretend center of ellipse is at origin, and rotation is 0
--- Also, adjust slope angle since we may have imaginarily rotated ellipse
- do important math stuff to determine 2 points where tangent line intersects
- translate those intersection points back to original ellipse placement
- finally, test if they're actually on the ellipse (ellipse could be open)
- throw a circle on the tangential points for user to see

 

;; Returns list of 4 ellipse details...
;; (centerPt majorRadis minorRadius rotationAngleToMajorRadius)
(defun EllipseInfo (e / eg)
  (setq eg (entget e))
  (list
    (cdr (assoc 10 eg))
    (getpropertyvalue e "MajorRadius")
    (getpropertyvalue e "MinorRadius")
    (angle '(0. 0. 0.) (cdr (assoc 11 eg)))
  )
)

;; Converts 2 tangential points at origin ellipse to corrected 'rotated' points around origin
;; pts - list, of 2 points as returned by 'TangentPointsAtOrigin'
;; eInfo - list, of 4 ellipse info items
(defun RotateOriginPoints (pts eInfo / ptZero r a)
  (setq ptZero '(0. 0. 0.))
  (setq r (distance ptZero (car pts)))
  (setq a (last eInfo))
  (mapcar
    '(lambda (p)
      (mapcar
        '(lambda (n f) (* r (f (+ a (angle ptZero p)))))
        p
        (list cos sin)
      )
    )
    pts
  )
);defun

;; Translates 2 ellipse tangent points (at origin) to current ellipse location
;; pts - list, of 2 tangent points near origin
;; eInfo - list, of 4 ellipse info items
;; returns - list, of 2 tangent points on ellipse
(defun TranslateOriginPoints (pts eInfo / )
  (mapcar
    '(lambda (p) (mapcar '+ (car eInfo) p))
    (RotateOriginPoints pts eInfo)
  )
);defun

;; Determines X coord val (in positive Y area) for ellipse w/ zero rotation at origin
;; ALWAYS assumes Major radius is in X-direction, minor in Y-direction
;; slope - real, slope of Tangent line we are trying to find coordinate of
;; xR - real, the MAJOR radius of the ellipse
;; yR - real, the MINOR radius of the ellipse
(defun SolveForXAtOrigin (slope xR yR / )
  (setq *x*
    (sqrt
      (/
        (* (expt slope 2) (expt xR 4))
        (+ (* (expt slope 2) (expt xR 2))
           (expt yR 2)
        )
      )
    )
  )
  (cond
    ((minusp slope) *x*)
    (t (- *x*))
  )
)

;; Determines positive Y coord val given corresponding X coord from 'SolveForXAtOrigin'
;; x - real, X coord value from 'SolveForXAtOrigin'
;; xR - real, the MAJOR radius of the ellipse
;; yR - real, the MINOR radius of the ellipse
(defun SolveForYAfterX (x xR yR / )
  (setq *y*
    (sqrt
      (- (expt yR 2)
         (* (/ (expt yR 2) (expt xR 2))
            (expt x 2)
         )
      )
    )
  )
)

;; Returns 2 points where tangent line intersects ellipse at origin
;; slope - real, slope of tangent line to be checked
;; eInfo - list, of 4 ellipse info items
;; returns - list, of 2 tangent points near origin
(defun TangentPointsAtOrigin (slope eInfo / p1 x)
  (list
    (setq p1
      (list
        (setq x (SolveForXAtOrigin slope (cadr eInfo) (caddr eInfo)))
        (SolveForYAfterX x (cadr eInfo) (caddr eInfo))
      )
    )
    (mapcar '- p1)
  )
);defun

;; Tangent - Lee Mac
;; Args: x - real
(defun tan ( x )
    (if (not (equal 0.0 (cos x) 1e-10))
        (/ (sin x) (cos x))
    )
)

;; Radians to Slope
;; r - real, radian value
;; returns - real, slope of radian value
(defun Rad2Slope (r / )
  (tan r)
)

;; Calculates Points where Tangent line intersects Ellipse (2 or fewer points)
;; e - ename, of ellipse
;; a - real, angle in radians of line tangent to ellipse
;; returns - list, of points where tangent slope intersects ellipse, or nil if none
(defun EllipseTangentPoints (e a / ev eInfo)
  (setq ev (vlax-ename->vla-object e))
  (setq eInfo (EllipseInfo e))
  (setq a (- a (last eInfo)))
  (vl-remove-if-not
    '(lambda (p) (vlax-curve-getParamAtPoint ev p))
    (TranslateOriginPoints
      (TangentPointsAtOrigin (Rad2Slope a) eInfo)
      eInfo
    )
  )
)

;; Creates circles (w/ 1 unit radius) at tangent points on selected ellipse
(defun c:TEST ( / ellipse a etp)
  (if (and (setq ellipse (car (entsel "\nSelect Ellipse: ")))
           (eq "ELLIPSE" (cdr (assoc 0 (entget ellipse))))
           (setq a 5.8)) ;<<--- DEFAULT TANGENT ANGLE PROVIDED BY JOHN !!! -----
    (progn
      (setq etp (EllipseTangentPoints ellipse a))
      (if etp
        (progn
          (prompt "\nEllipse tangent points are: ") (print etp)
          (foreach p etp
            (command "_.CIRCLE" "_non" p 1)
          )
        )
      ;else
        (prompt "\n...No ellipse tangent points were found!")
      )
    )
  ;else
    (prompt "\nMust select an ELLIPSE.")
  )
  (princ)
)

 

Best,

~DD

0 Likes
Message 36 of 48

dbroad
Mentor
Mentor

Picky picky

 

;;safe tangent function
(defun tan  (ang)
  (if (zerop (cos ang))
    (/ (sin ang) 1e-308)
    (/ (sin ang) (cos ang))))

;;flatlist to point list
(defun groupby3	 (lst)
  (if (null lst)
    nil
    (cons (cons (car lst) (cons (cadr lst) (cons (caddr lst) nil)))
	  (groupby3 (cdddr lst)))))

;;Return angle of first derivative at point
;;Return value constrained to 0 <= angle <= 2pi
(defun fderivangatpt  (curve pt / param fderiv tentativeangle)
  (setq	param	       (vlax-curve-getparamatpoint curve pt)
	fderiv	       (vlax-curve-getfirstderiv curve param)
	tentativeangle (atan (cadr fderiv) (car fderiv)))
  (if (minusp tentativeangle)		;force angles to be positive
    (+ (* 2 pi) tentativeangle)
    tentativeangle))


;;given ellipse ename and angle in radians, find points at which lines drawn in that direction would
;;be tangent to the ellipse
;;D. C. Broad, Jr.
;;Adjusted for 2d rotation and translation but not for 3d rotation.
;;Not tested for non-WCS state.
(defun ptonellipse  (ellipse	   ang	  /	 2pi	a      ang2   b	     ctr    eo
		     majaxis	   minaxis	 msp	phi    pt     ptlst  pts    return
		     rot    theta  xline)
  (setq 2pi (* 2 pi))			;probably unecessary but keeping angles between 0 and 2pi
  (setq eo (vlax-ename->vla-object ellipse)) ;convert to object 
  (setq majaxis (vlax-get eo 'majoraxis))
  (setq rot (rem (angle '(0 0 0) majaxis) 2pi)) ;determine ellipse rotaton
  (setq ang2 (- ang rot))		;adjust ang by counter rotating.
  (setq phi (rem (+ ang2 2pi (/ pi 2)) 2pi)) ;perpendicular to ang2.
  (setq minaxis (vlax-get eo 'minoraxis))
  (setq ctr (vlax-get eo 'center))
  (setq a (distance '(0 0 0) majaxis))	;semimajor axis length
  (setq b (distance '(0 0 0) minaxis))	;semiminor axis length
  (setq theta (atan (* (tan phi) (/ (* b b) (* a a))))) ;angle conversion (key)
  (setq msp (vla-get-modelspace (vla-get-document eo)))
  (setq	xline (vla-addxline
		msp
		(vlax-3d-point ctr)
		(vlax-3d-point (polar ctr (+ theta rot) 1)))
	pts   (vlax-invoke eo 'intersectwith xline acextendnone)
	ptlst (groupby3 pts))
  (vla-delete xline)
  (foreach pt  ptlst
    (if	(equal ang (fderivangatpt ellipse pt) 1e-8) ;eliminate additional tangents
      (progn (setq return pt)
	     (vla-addpoint msp (vlax-3d-point pt)))) ;side effect = draw point.
    )
  return)

 

If you want tangents relative to closed ellipses, including those off the elliptical arc, change acextendnone to acExtendThisEntity.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 37 of 48

john.uhden
Mentor
Mentor

@CodeDing 

I'll check it out.

Be careful with your Rad2Slope function.

(tan (* pi 0.25)) = (tan (*pi 1.25))

John F. Uhden

Message 38 of 48

john.uhden
Mentor
Mentor

@dbroad 

I'll have to try to digest all that.

Perhaps there's a way to trigonometrically do the xline stuff, or at least entmake the xline so it can be invisible at birth (though its life span is quite abbreviated).

John F. Uhden

0 Likes
Message 39 of 48

doaiena
Collaborator
Collaborator
Accepted solution

I think i found a fast and precise solution. The function works for ellipses centered at 0,0,0. It returns both points of tangency. With some slight modifications, the function could be made to work exactly the way u want it.

(defun test (ellipse ang / tan obj radMaj radMin cen pt)
;; Tangent  -  Lee Mac
;; Args: x - real
(defun tan ( x ) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x))))

(setq obj (vlax-ename->vla-object ellipse))
(setq radMaj (vlax-get obj 'MajorRadius))
(setq radMin (vlax-get obj 'MinorRadius))
(setq cen (vlax-get obj 'Center))
(setq ang (- ang (angle cen (vlax-get obj 'MajorAxis))))

(setq pt (list
(/ (* (expt radMaj 2.0) (tan ang)) (sqrt (+ (* (expt radMaj 2.0) (expt (tan ang) 2.0)) (expt radMin 2.0))))
(* (/ (expt radMin 2.0) (sqrt (+ (* (expt radMaj 2.0) (expt (tan ang) 2.0)) (expt radMin 2.0)))) -1)
0
))

(setq pt (polar cen (+ (angle '(0 0 0) pt) (angle cen (vlax-get obj 'MajorAxis))) (distance '(0 0 0) pt)))
(list pt (list (* (car pt) -1) (* (cadr pt) -1) 0))
);defun
0 Likes
Message 40 of 48

john.uhden
Mentor
Mentor

@doaiena 

Well, the ellipse I provided is not at 0,0 so you have to take care of that.

And, yes please, just one point where the angular direction of the first derivative equals the input angle (± fuzz).

That was my specified intention, so in all fairness I have to stick with it.

I think I like it a lot.

John F. Uhden

0 Likes