Author Topic: Test Points  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Test Points
« on: October 03, 2007, 06:28:34 PM »
If I had the user pick to points using....

Code: [Select]
(setq Pt1 (getpoint "\nSpecify first corner: "))
  (setq Pt2 (getcorner Pt1 "Specify opposite corner: "))

How could I test to see if the window was taller then it is wide?


T.Willey

  • Needs a day job
  • Posts: 5251
Re: Test Points
« Reply #1 on: October 03, 2007, 06:31:26 PM »
Code: [Select]
(setq xDist (abs (- (car Pt1) (car Pt2))))
(setq yDist (abs (- (cadr Pt1) (cadr Pt2))))
(if (> xDist yDist)
 (prompt "\n Longer than taller.")
 (prompt "\n Taller than longer.")
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Test Points
« Reply #2 on: October 03, 2007, 07:06:22 PM »
Tim you forgot one.
Code: [Select]
(cond
 ((= xDist yDist)
  (prompt "\n Window is just right."))
 ((> xDist yDist)
  (prompt "\n Longer than taller."))
 (t
  (prompt "\n Taller than longer."))
)
:lmao:
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Test Points
« Reply #3 on: October 03, 2007, 07:10:04 PM »
Tim you forgot one.
Code: [Select]
(cond
 ((= xDist yDist)
  (prompt "\n Window is just right."))
 ((> xDist yDist)
  (prompt "\n Longer than taller."))
 (t
  (prompt "\n Taller than longer."))
)
:lmao:
Oh Alan...... At least correct me the correct way.  :wink:
Code: [Select]
(cond
 ((equal xDist yDist 0.000001)
  (prompt "\n Window is just right."))
 ((> xDist yDist)
  (prompt "\n Longer than taller."))
 (t
  (prompt "\n Taller than longer."))
)
:lmao:  Good one though......
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Test Points
« Reply #4 on: October 03, 2007, 07:25:21 PM »
Never meant for it to be used, just a vehicle for some lame humor. No correction intended.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Test Points
« Reply #5 on: October 03, 2007, 10:15:25 PM »
Never meant for it to be used, just a vehicle for some lame humor. No correction intended.
I took it as such, and I needed it today.  Thanks.  :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Test Points
« Reply #6 on: October 04, 2007, 01:49:11 AM »
Hi,

Just for fun, using grread, grvecs and grtext to display the result in real time on the status line

Code: [Select]
((lambda ()
   (setq pt1 (getpoint "\nFirst corner: "))
   (princ pt1)
   (princ "\nOpposite corner: ")
   (while (and (setq gr (grread T 4 0)) (/= (car gr) 3))
     (redraw)
     (setq pt2 (cadr gr)
   xd  (abs (- (car pt1) (car pt2)))
   yd  (abs (- (cadr pt1) (cadr pt2)))
     )
     (grvecs (list (list (car pt1) (cadr pt1))
   (list (car pt2) (cadr pt1))
   (list (car pt2) (cadr pt1))
   (list (car pt2) (cadr pt2))
   (list (car pt2) (cadr pt2))
   (list (car pt1) (cadr pt2))
   (list (car pt1) (cadr pt2))
   (list (car pt1) (cadr pt1))
     )
     )
     (cond
       ((< xd yd) (grtext -1 "Taller than longer"))
       ((< yd xd) (grtext -1 "Longer than taller"))
       (T (grtext -1 "Perfect square"))
     )
   )
   (grtext)
   (princ pt2)
   (princ)
 )
)
Speaking English as a French Frog