Jump to content

Recommended Posts

Posted
These constraints do not define a unique rectangle:

 

[ATTACH]43185[/ATTACH]

 

Strictly speaking you are correct Lee. But they do if you always pick the same three sides of the rectangle.

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • Tyke

    10

  • Lee Mac

    4

  • Tharwat

    4

  • hmsilva

    4

Top Posters In This Topic

Posted Images

Posted

Just for fun.

A quick one, minimally tested...

 

(defun c:test (/ P1 P2 P3 P4)
 (prompt "\nSelect all points clockwise or counterclockwise! ")
 (command "ucs" "_W")
 (setq p1 (getpoint "\nSelect the corner point: ")
p2 (getpoint "\nselect a point to define the rectangle orientation: ")
 );; setq
 (command "ucs" p1 (trans p2 0 1) "")
 (setq p3 (getpoint "\nSelect next point: ")
p4 (getpoint "\nSelect last point: ")
p1 (trans p1 0 1)
p2 (trans p2 0 1)
 );; setq
 (command "_rectang"
   "_non"
   p1
   "_non"
   (inters p3
    (polar p3 (+ (/ pi 2) (angle p1 p2)) 1)
    p4
    (polar p4 (angle p1 p2) 1)
    nil
   )
   "ucs"
   "_P"
 );; command
 (princ)
);; test

 

Henrique

Posted

Henrique, that works fine. I believe it is what the OP wanted, let's see if he gets back and tells us. From his avatar he could be a surveyor, so he would survey just one corner and then a point on three sides. We always surveyed three corners and it was easy enough to construct the rectangle from that.

Posted
Henrique, that works fine. I believe it is what the OP wanted, let's see if he gets back and tells us. From his avatar he could be a surveyor, so he would survey just one corner and then a point on three sides. We always surveyed three corners and it was easy enough to construct the rectangle from that.

 

Let's wait and see...

Posted

thank you hmsilva and Tyke nice job . It works fine

:beer: Cheers, my friends! ...

Posted

You're welcome, prodromosm

Glad I could help

 

Henrique

Posted

Another version perhaps:

(defun c:test2 ( / a1 p1 p2 p3 p4 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
           (setq p3 (getpoint "\nPick 3rd point: " p2))
           (setq p4 (getpoint "\nPick 4th point: " p3))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non"
           (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil)
       )
   )
   (princ)
)

Or, if three points will suffice:

(defun c:test3 ( / p1 p2 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\")
   )
   (princ)
)

Posted
thank you hmsilva and Tyke nice job . It works fine

:beer: Cheers, my friends! ...

 

I didn't do anything really the thanks need to go to the guys who wrote the LISP routines.

Posted
Another version perhaps:

(defun c:test2 ( / a1 p1 p2 p3 p4 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
           (setq p3 (getpoint "\nPick 3rd point: " p2))
           (setq p4 (getpoint "\nPick 4th point: " p3))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non"
           (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil)
       )
   )
   (princ)
)

Or, if three points will suffice:

(defun c:test3 ( / p1 p2 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\")
   )
   (princ)
)

 

As ever Lee - fantastic. :notworthy: :thumbsup:

Posted
Another version perhaps:

(defun c:test2 ( / a1 p1 p2 p3 p4 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
           (setq p3 (getpoint "\nPick 3rd point: " p2))
           (setq p4 (getpoint "\nPick 4th point: " p3))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non"
           (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil)
       )
   )
   (princ)
)

Or, if three points will suffice:

(defun c:test3 ( / p1 p2 )
   (if
       (and
           (setq p1 (getpoint "\nPick vertex point: "))
           (setq p2 (getpoint "\nPick 2nd point: " p1))
       )
       (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\")
   )
   (princ)
)

 

Lee,

the test2, was giving a small error in the rotation because it depends from defined precision in "Units", defining precision for more decimal places, worked without error.

As always, nice code!

 

Henrique

Posted
Did not you find my code of any use ? :danger:

 

Tyke explained earlier that your program is restricted to generating rectangles that are orthogonal to the WCS axes and hence not suitable for a generic case.

 

Why are you angry? :?

Posted
Tyke explained earlier that your program is restricted to generating rectangles that are orthogonal to the WCS axes and hence not suitable for a generic case.

 

My post was related to THIS explanation from the OP .

 

Why are you angry? :?

 

No at all , it is just a tickle . :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...