Author Topic: Equal Length Lines  (Read 2430 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Equal Length Lines
« on: May 11, 2016, 12:48:02 PM »
Maybe I'm over thinking this 1

From a known distance between the 2 parallel blue lines ( 28 ) and a specified miter angle ( 30 Deg )

To calculate the geometry of the yellow green and cyan show that the 3 lines are equal length

I know there would have to be some limits to the angle

Any suggestions ?  Thanks  -David
R12 Dos - A2K

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Equal Length Lines
« Reply #1 on: May 11, 2016, 12:59:20 PM »
Sorry - removed my previous post. The 3 lines need to be equal length - got it. I will have to think about this one...
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Equal Length Lines
« Reply #2 on: May 11, 2016, 01:00:53 PM »
On first glance, if the separation is d, then the line length will be d/(1+2cos(30))

Quick diagram:

« Last Edit: May 11, 2016, 01:05:59 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Equal Length Lines
« Reply #3 on: May 11, 2016, 01:24:42 PM »
In code:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:miter ( / ang len lst nor pt1 pt2 vec )
  2.     (if (and (setq pt1 (getpoint "\n1st point: "))
  3.              (setq pt2 (getpoint "\n2nd point: " pt1))
  4.              (progn
  5.                  (while (and (setq ang (getangle "\nMiter angle: ")) (not (< 0 ang (/ pi 2.0))))
  6.                      (princ "\nMiter angle must be between 0 & 90 degrees.")
  7.                  )
  8.                  ang
  9.              )
  10.         )
  11.         (progn
  12.             (setq nor (trans (mapcar '- pt2 pt1) 1 0 t)
  13.                   len (/ (distance pt1 pt2) (1+ (* 2 (cos ang))))
  14.                   vec (list (* -1 len (sin ang)) 0 (* len (cos ang)))
  15.                   lst (list (trans pt1 1 0)
  16.                             (trans (mapcar '+ (trans pt1 1 nor) vec) nor 0)
  17.                             (trans (mapcar '- (trans pt2 1 nor) (cons (- (car vec)) (cdr vec))) nor 0)
  18.                             (trans pt2 1 0)
  19.                       )
  20.             )
  21.             (mapcar '(lambda ( a b ) (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))) lst (cdr lst))
  22.         )
  23.     )
  24.     (princ)
  25. )

Compatible in UCS planes parallel to the WCS plane.
« Last Edit: May 11, 2016, 01:29:57 PM by Lee Mac »

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Equal Length Lines
« Reply #4 on: May 11, 2016, 01:31:22 PM »
Lee, you are correct !  (as usual )


My simple test bed :
Code: [Select]
  (initget 7)
  (setq d (getdist "\nDistance:   "))

  (initget 7)
  (setq a (getangle "\nMiter Angle:   "))

  (setq x (/ d (1+ (* 2 (cos a)))))

  (alert (rtos x 2 4))

Real world application - mitered end end of a salad bar ( i estimated these but they will have to exact for fabrication )

THANKS!  -David

R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Equal Length Lines
« Reply #5 on: May 11, 2016, 01:32:52 PM »
You're welcome David - Nice render!  :-)

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Equal Length Lines
« Reply #6 on: May 11, 2016, 05:13:09 PM »
Nice Lee! - I knew there was a way to do it with trig, but my math skills are rusty.  :uglystupid2:
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

paulmcz

  • Bull Frog
  • Posts: 202
Re: Equal Length Lines
« Reply #7 on: May 11, 2016, 08:41:51 PM »
No need for math for this:

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Equal Length Lines
« Reply #8 on: May 12, 2016, 09:36:27 AM »
Based on Lee's trig function, this will make the pline edge path and the surfaces :

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mitertop (/ x y hy w a l pb pt ly ll lr ur ul bn)
  2.  
  3.   (initget 7)
  4.   (setq x (getdist "\nOverall S-S Distance:   "))
  5.  
  6.   (initget 6)
  7.   (setq y (getdist "\nF-B Distance <28>:   "))
  8.   (or y (setq y 28))
  9.   (setq hy (* y 0.5))
  10.  
  11.   (initget 6)
  12.   (setq w (getdist "\nWork Surface SFF <34>:   "))
  13.   (or w (setq w 34))
  14.  
  15.   (initget 7)
  16.   (setq a (getangle "\nMiter Angle:   "))
  17.  
  18.   (setq l (/ y (1+ (* 2 (cos a))))
  19.        pb (polar (list 0 (- hy) w) (- (* pi 0.5) a) l)
  20.        pt (polar (list 0 (+ hy) w) (+ (* pi 1.5) a) l)
  21.        ly (- (- x (cadr pt)))
  22.        ll (list ly (- hy) w)
  23.        lr (list  0 (- hy) w)
  24.        ur (list  0 (+ hy) w)
  25.        ul (list ly (+ hy) w))
  26.  
  27.   (entmake (list (cons 0 "BLOCK")(cons 2 "*U")(cons 70 1)(list 10 0 0 0)))
  28.   (entmake (list (cons 0 "3DFACE")(cons 8 "3D")(cons 70 1)
  29.                  (list 10  0 (- hy) w)
  30.                  (list 11  0 (+ hy) w)
  31.                  (list 12 ly (+ hy) w)
  32.                  (list 13 ly (- hy) w)))
  33.   (entmake (list (cons 0 "3DFACE")(cons 8 "3D")(cons 70 1)
  34.                  (list 10 0 (+ hy) w)
  35.                  (list 11 0 (- hy) w)
  36.                  (cons 12 pb)
  37.                  (cons 13 pt)))
  38.   (entmake (list (cons 0 "POLYLINE")(cons 8 "3D")
  39.                  (cons 10 (list 0 0 w))(cons 39 -1)
  40.                  (cons 66 1)(cons 70 1)))
  41.   (foreach v (list ll lr pb pt ur ul)
  42.      (entmake (list (cons 0 "VERTEX")(cons 8 "3D")
  43.                     (cons 10 v)(cons 70 0))))
  44.   (entmake (list (cons 0 "SEQEND")(cons 8 "3D")))
  45.  
  46.   (setq bn (entmake (list (cons 0 "ENDBLK")(cons 8 "0"))))
  47.  
  48.   (entmake (list (cons 0 "INSERT")(cons 2 bn)(list 10 (abs ly) 0 0)))
  49.   (prin1))
  50.  
  51.  


Thanks again  -David
R12 Dos - A2K

PKENEWELL

  • Bull Frog
  • Posts: 320
Re: Equal Length Lines
« Reply #9 on: May 12, 2016, 12:55:37 PM »
No need for math for this:

True - but a mathematical method is needed to do this in code.  :-)
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

ScottMC

  • Newt
  • Posts: 194
Re: Equal Length Lines
« Reply #10 on: April 21, 2018, 11:38:34 PM »
Can the "F-B Distance:" or "Y" be moved to Previous Pick/point as it's at the mid when drawn? Also, The "DEGree" symbol added to Lisp text prompt is (chr 186)!    :uglystupid2:
« Last Edit: April 28, 2018, 05:21:41 PM by ScottMC »