Author Topic: arc challenge  (Read 16242 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
arc challenge
« Reply #30 on: January 24, 2004, 12:41:01 PM »
Wow, what a brain teaser that was.. (or is)

But I think I got the LISP version working.

Keith, yours works but if I use crossing line as the distance reference
Your routine will pick it up as the line choice. Just an observation.

Don, I could not get the patches to work, maybe I inserted them wrong.
Didn't spend mush time trying to figure it out.

I'm not going to tell how nuch time I spent. :)

Code: [Select]
(defun c:tanarc2 (/ ang   ang1  ang2  bang cpt   dst   dst2  e1
 e2 flag  ipt   p1  p2 p3    p4    pt  pt1
 pt2 ipt   ptc   90deg 180deg      270deg  360deg
)
   ;; compute the delta angle between a1 & a
  (defun @delta (a1 a2)
   (cond
    ((> a1 (+ a2 pi)) (- (+ a2 pi pi) a1))
    ((> a2 (+ a1 pi)) (abs(- a2 a1 pi pi)))
    ((- a2 a1))
   )
  )
  ;; find the line angle closest to angle to picked point for the line selection
  (defun angequal (ang12 pkpt)
    (or (equal ang12 pkpt 0.1)
(and (< pkpt (+ ang12 90deg))
    (> pkpt (- ang12 90deg))
)
(and (> (+ ang12 90deg) 360deg)
    (> pkpt (- ang12 90deg))
    (< pkpt (- (* pi 2.5) ang12))
)
    )
  )


  ;; determine the first angle in a ccw direction
  (defun startang ()
    (cond
      ((equal (+ ang1 ang) ang2 0.1) ang1)
      ((equal (+ ang2 ang) ang1 0.1) ang2)
      ((< (+ ang1 ang) ang2) ang2)
      (t ang1)
    )
  )

  (prompt "Pick 2 Lines, Arc Start Point First..")
  (setvar "osmode" 176)
  (setq e1     (entsel "\nPick first line: ")
e2     (entsel "\nPick second line: ")
pt     (getpoint "\nPick start point on line: ")
flag   nil
90deg  (* pi 0.5)
180deg pi
270deg (* pi 1.5)
360deg (* pi 2)
  )
  (setvar "osmode" 0)

  (and (and e1 e2 pt)
       (setq p1 (cdr (assoc 10 (entget (car e1)))))
       (setq p2 (cdr (assoc 11 (entget (car e1)))))
       (setq p3 (cdr (assoc 10 (entget (car e2)))))
       (setq p4 (cdr (assoc 11 (entget (car e2)))))
       (setq ipt (inters p1 p2 p3 p4 nil))

       (if (angequal (angle p1 p2) (angle ipt (cadr e1)))
          (setq ang1 (angle p1 p2))
          (setq ang1 (angle p2 p1))
       )
       (if (angequal (angle p3 p4) (angle ipt (cadr e2)))
          (setq ang2 (angle p3 p4))
          (setq ang2 (angle p4 p3))
       )
       (setq dst (distance ipt pt))
       (setq pt1 (polar ipt ang1 dst))
       (setq pt2 (polar ipt ang2 dst))

       (setq ang (@delta ang1 ang2))
       (setq bang (/ ang 2))

       (setq dst2 (/ dst (cos bang)))
       (setq sang (startang))
       (setq cpt (polar ipt (+ bang sang) dst2))
       (setq ptc (polar cpt (+ pi (+ bang sang)) (distance cpt pt1)))
       (setq flag t)
  )
  (if flag
    (command "_.arc" pt1 ptc pt2)
    (alert "User Error")
  )
 
  (princ)
)
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Guest

  • Guest
arc challenge
« Reply #31 on: January 29, 2004, 10:36:47 PM »
"I need to draw an arc (or a circle), defined by two tangents and a point on the circle -- not a radius like TTR."

The way that I would draw that is:

1.  Locate the 2nd point at the same distance from the vertex by using  Circle, Radius

2.  Draw the arc using the Start, End, Direction option

3.  Delete construction and trim as needed  

Odon

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #32 on: January 29, 2004, 11:38:29 PM »
Example my man .... we need an example ....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Kate M

  • Guest
arc challenge
« Reply #33 on: January 30, 2004, 09:14:27 AM »
Quote
1. Locate the 2nd point at the same distance from the vertex by using Circle, Radius

The problem was that I didn't *know* the radius...just a start or end point and the two tangents.

daron

  • Guest
arc challenge
« Reply #34 on: January 30, 2004, 09:29:21 AM »
I think guest was trying to take over your thread Kate. Should I move him to his own thread?

Kate M

  • Guest
arc challenge
« Reply #35 on: January 30, 2004, 09:45:18 AM »
No, I think he was quoting my first post.

SMadsen

  • Guest
arc challenge
« Reply #36 on: January 30, 2004, 10:08:32 AM »
Quote from: Kate M
Quote
1. Locate the 2nd point at the same distance from the vertex by using Circle, Radius

The problem was that I didn't *know* the radius...just a start or end point and the two tangents.

This is how I would draw it, too. You don't need the radius but you do need two points: the intersection point and the start point:



Command: ARC
Specify start point of arc or
: [pick start point]
Specify second point of arc or [Center/End]: End
Specify end point of arc: [pick end point]
Specify center point of arc or [Angle/Direction/Radius]: Direction
Specify tangent direction for the start point of arc: [pick a point in the direction, e.g. intersection point]

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
arc challenge
« Reply #37 on: January 31, 2004, 02:27:32 PM »
Never used Direction before. It simplifys things a bit.

Here is my code modified to use the direction method.

Code: [Select]
(defun c:tanarc2 (/ ang   ang1  ang2  bang cpt   dst   dst2  e1
 e2 flag  ipt   p1  p2 p3    p4    pt  pt1
 pt2 ipt   ptc   90deg 180deg      270deg  360deg
)
  ;; find the line angle closest to angle to picked point for the line selection
  (defun angequal (ang12 pkpt)
    (or (equal ang12 pkpt 0.1)
(and (< pkpt (+ ang12 90deg))
    (> pkpt (- ang12 90deg))
)
(and (> (+ ang12 90deg) 360deg)
    (> pkpt (- ang12 90deg))
    (< pkpt (- (* pi 2.5) ang12))
)
    )
  )



  (prompt "Pick 2 Lines, Arc Start Point First..")
  (setvar "osmode" 176)
  (setq e1     (entsel "\nPick first line: ")
e2     (entsel "\nPick second line: ")
pt     (getpoint "\nPick start point on line: ")
flag   nil
90deg  (* pi 0.5)
180deg pi
270deg (* pi 1.5)
360deg (* pi 2)
  )
  (setvar "osmode" 0)

  (and (and e1 e2 pt)
       (setq p1 (cdr (assoc 10 (entget (car e1)))))
       (setq p2 (cdr (assoc 11 (entget (car e1)))))
       (setq p3 (cdr (assoc 10 (entget (car e2)))))
       (setq p4 (cdr (assoc 11 (entget (car e2)))))
       (setq ipt (inters p1 p2 p3 p4 nil))

       (if (angequal (angle p1 p2) (angle ipt (cadr e1)))
          (setq ang1 (angle p1 p2))
          (setq ang1 (angle p2 p1))
       )
       (if (angequal (angle p3 p4) (angle ipt (cadr e2)))
          (setq ang2 (angle p3 p4))
          (setq ang2 (angle p4 p3))
       )
       (setq dst (distance ipt pt))
       (setq pt1 (polar ipt ang1 dst))
       (setq pt2 (polar ipt ang2 dst))

       (setq flag t)
  )
  (if flag
    (command "_.arc" pt1 "en" pt2 "d" ipt)
    (alert "User Error")
  )

  (princ)
)
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kate M

  • Guest
arc challenge
« Reply #38 on: February 02, 2004, 09:28:32 AM »
Huh...I'd tried direction before, but I must not have been picking the right start tangent or something, because it never came out quite right...works now, though. Learn something new every day, right? :-) Thanks for all the help!!!