Author Topic: arc challenge  (Read 16248 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
arc challenge
« Reply #15 on: January 22, 2004, 02:37:43 PM »
Here's a graphic of the points calculated in TANARC, if anyone should happen to be interested in playing with it:



Wow, bad quality!

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #16 on: January 22, 2004, 09:46:01 PM »
Ok, I took it upon myself to put together the proggie Kate needs .... you can get it here

Kate, let me know if it suits your needs
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

DParcon

  • Guest
arc challenge
« Reply #17 on: January 22, 2004, 11:09:20 PM »
Kate,

Here's a routine that takes care of arc direction,
based on Stig's routine/diagram (pure Autolisp,
points calculation and using arcs' command
3-points option).

Code: [Select]


(defun C:TANARC2 (/ ang ang1 ang2 bang cpt dst dst2 e1 e2
                    flag fuzz ipt p1 p2 p3 p4 pt pt1 pt2 rad)
  (prompt "Pick 2 Lines, Arc Start Point First..")
  (setq e1 (entsel "\nPick first line: ")
        e2 (entsel "\nPick second line: ")
        pt (getpoint "\nPick start point on line: ")
        flag nil
        fuzz 1e-12
  )
  (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))
       (setq ang1 (angle ipt pt))
       (setq ang2 (if (< (distance ipt p3) (distance ipt p4))
                    (angle ipt p4)
                    (angle ipt p3)
                  )
       )
       (setq ang (* (+ ang1 ang2) 0.5))
       (setq dst (distance ipt pt))
       (setq bang (abs (- ang ang1)))
       (setq dst2 (/ dst (cos bang)))
       (setq cpt (polar ipt ang dst2))
       (setq rad (distance cpt pt))
       (setq pt1 (polar cpt (+ ang pi) rad))
       (setq pt2 (polar ipt ang2 dst))
       (setq flag T)
  )
  (if flag
    (command "_.arc" pt pt1 pt2)
    (Alert "User Error")
  )
)



Enjoy.

Kate M

  • Guest
arc challenge
« Reply #18 on: January 23, 2004, 09:28:27 AM »
Keith - that worked fabulously! Thanks!

Don - I couldn't get it to work unless the original lines were in a "V" shape (not upside-down or sideways). Am I missing something?

Thanks again -- you guys are awesome. :-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #19 on: January 23, 2004, 10:47:17 AM »
Kate, the problem mentioned by Stig is also the same problem within Don's routine. What happens is that while the points that define the arc are exact, the method for getting them can give an inaccurate center point or the arc IF either of the lines angle fits this profile : 180 < angle < 0

The same thing can happen IF the line is drawn in the opposite direction, instead of drawing the lines from left to right, if they were drawn from right to left it buggers up the code without some more error checking.

So, to put the whole thing together and eliminate the need for a whole lot of error checking, the key was to have the user select the beginning tangent point and the line to have a matching point. Using each point, we needed to find the intersection of both of those point at 90deg from the line they are located on.

So, basically it is ..
Code: [Select]

(setq center (inters pt1 pt2 pt3 pt4))


Now we know that the distance between pt1 and center is the radius of the arc, AND it will always be on the smaller angle side of the lines because there is no intersection of the lines on the larger angle side.

So, you have the point selected by the user, and the center of the arc, now all you need to do is draw an arc from PT1 using a radius of (distance pt1 center) to PT3 which is a point lying on the second line an equal distance from the intersection of the two lines to PT1.

The only error checking reqired is to make sure the arc is drawn using the correct beginning angle, otherwise it creates the arc representing the remaining portion of the circle.

Not really too difficult, but I wanted to make it as simple for the end user as possible. I am glad it worked out ok.
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

SMadsen

  • Guest
arc challenge
« Reply #20 on: January 23, 2004, 11:16:06 AM »
DParcon, cool that you played some with the function. Although switching the points based on direction did some of it, it doesn't cut it all the way.

Keith, it didn't quite work, either. Guess we need to determine which "quadrant" is being picked?


Oh I love to make comments without making suggestions on my own :)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #21 on: January 23, 2004, 11:30:23 AM »
Mine didn't work, or the modifications to yours didn't work, I am confused...
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

SMadsen

  • Guest
arc challenge
« Reply #22 on: January 23, 2004, 11:38:06 AM »
None of them works outside the scope of the specific situation that Kate illustrated.

Kate M

  • Guest
arc challenge
« Reply #23 on: January 23, 2004, 12:31:23 PM »
Guess this is a little more complicated than I thought it would be... :-)

daron

  • Guest
arc challenge
« Reply #24 on: January 23, 2004, 12:32:20 PM »
You did say it was a challenge. Well, you were right.

deegeecees

  • Guest
arc challenge
« Reply #25 on: January 23, 2004, 12:34:25 PM »
use the sketch command...

Problem solved! :D

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #26 on: January 23, 2004, 12:58:34 PM »
Ok well let me revisit it then ...
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

DParcon

  • Guest
arc challenge
« Reply #27 on: January 23, 2004, 04:39:48 PM »
Kate,

 Here's some minor alterations to the routine I've
 posted. This will probably solved the current arc
 direction problems (no rigorous testing done)
 particularly on the 1st/4th quadrant scenarios.
 
 Change the statements for ang2 and ang as
 shown below:

 
Code: [Select]


       (setq ang2 (angle ipt (cadr e2)))
       (setq ang (if (> (setq ang (* (+ ang1 ang2) 0.5)) pi)
                   (- ang pi)
                   ang
                 )
       )

 


 For additional accuracy, you can calculate the actual values
 of the line angles using the endpoints. You can change the
 fuzz factor if you want (currently @ 0.57 degree).The changes
 will include ang1, ang2 & ang as in the code shown below:
 
 
Code: [Select]

     
       (setq ang1 (if (equal (angle ipt pt) (angle p1 p2) 0.01)
                     (angle p1 p2)
                     (angle p2 p1)
                 )
       )      
       (setq ang2 (if (equal (angle ipt (car e2)) (angle p3 p4) 0.01)
                    (angle p3 p4)
                    (angle p4 p3)
                 )
       )
       (setq ang (if (> (setq ang (* (+ ang1 ang2) 0.5)) pi)
                   (- ang pi)
                   ang
                 )
       )

 


 I believe these changes will cover all possible applications
 you have (hopefully).

DParcon

  • Guest
arc challenge
« Reply #28 on: January 23, 2004, 06:21:30 PM »
Kate,

 The "ang" calculation in my previous post is not
 entirely correct (won't work in some instances).
 Also, in the calculation of "ang2", change (car e2)
 to (cadr e2) which is the pick point.
 
 The final calculation for "ang" is shown below and
 considers if each line is either in the 1st or 4th
 quadrant.

   
Code: [Select]


   (setq ang (if (or (and (< 0 ang1 (* pi 0.5))
                          (< (* pi 1.5) ang2 (* pi 2.0))
                     )
                     (and (< (* pi 1.5) ang1 (* pi 2.0))
                          (< 0 ang2 (* pi 0.5))
                     )  
                 )  
               (- (* (+ ang1 ang2) 0.5) pi)
               (* (+ ang1 ang2) 0.5)
             )
   )

   


 With these changes, the routine will now work provided
 the start point of the arc is located on the first line and
 on the same side where the line was picked.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
arc challenge
« Reply #29 on: January 24, 2004, 01:42:43 AM »
Ok Kate, (and others) here is the updated version.
It now works in each quadrant.

Test it out and give feedback as needed..
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