Author Topic: Calculating points  (Read 1974 times)

0 Members and 1 Guest are viewing this topic.

Shade

  • Guest
Calculating points
« on: March 13, 2007, 01:13:14 PM »
I am writing a lisp to draw a gable roof, and I am having trouble calculating the points necessary to complete the roof.
I am having trouble calculating points PT6 and PT7 in the example provided.
PT6 and PT7 are needed to get PT8.
All other points listed in the example (attached) I have already found.
The rise of the roof is a variable number from 1 to 12 and therefore the pitch will always be a number over 12.
All other dimensions in the example are fixed and will never change.
Any  help would be greatly appreciated.
Thanks in advance…


Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Calculating points
« Reply #1 on: March 13, 2007, 02:15:44 PM »
Quick and dirty ... should be self explanitory .. lots of cleanup could be performed with it as well ..

Code: [Select]
(defun getPnt (pt1 pt2 pt5)
  (setq temppt1 (polar pt1 (- (angle pt1 pt2) (ANGTOF "90")) 6)
temppt2 (polar pt2 (- (angle pt1 pt2) (ANGTOF "90")) 6)
temppt3 (polar pt5 (ANGTOF "90") 12)
temppt4 (polar pt2 (- (angle pt2 pt3) (angtof "90")) 6)
  )
  (setq pt7 (inters temppt1 temppt2 pt5 temppt3 nil)
pt6 (polar pt7 0 (- (distance pt1 pt3) 56))
pt8 (inters pt7 temppnt2 pt6 temppnt4 nil)
  )
  (vl-cmdf "_.line" pt7 pt8 pt6 "")
)
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

Shade

  • Guest
Re: Calculating points
« Reply #2 on: March 14, 2007, 12:34:56 AM »
Thanks, Keith.
It took me a little while before I could see how you did it, but i got it.

Cheers mate!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Calculating points
« Reply #3 on: March 14, 2007, 10:20:36 AM »
Here is another take on the problem.
Code: [Select]
(defun c:test2 (/ p1 p2 p5 p7 p8 s1)

  (setq p1 (getpoint "\nPick point P1"))
  (setq p2 (getpoint "\nPick point P2"))
  (setq p5 (getpoint "\nPick point P5"))
  (setq s1 6.0)

  (setq p8 (polar p2 (* pi 1.5) (/ s1 (sin (- (/ pi 2) (angle p1 p2))))))
  (setq p7 (inters p5 (polar p5 (/ pi 2) 100)
                  p8 (polar p8 (angle p2 p1) 100) nil))

  (command ".point" "_non" p8)
  (command ".point" "_non" p7)

  (princ)
)
« Last Edit: March 14, 2007, 10:22:22 AM by CAB »
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.