Jump to content

Recommended Posts

Posted

hi

 

how can i tell if 3 points form a corner? what about giving it some tolerance? lets say its still a corner if it didn't exceed 80-100 degrees range?

 

 

 

Thanks

Shay

Posted

lets say i have a list containing those 3 points, i want it to tell me if they form a 90 degree corner, and if its still between 80 to 100 degree, its ok..ill take it as a rorner as well :P:P:P

corner.jpg

Posted

There are many ways to approach the task, here is one:

(defun corner-p ( p1 p2 p3 )
   (equal 0.0 (apply '+ (mapcar '* (mapcar '- p3 p2) (mapcar '- p1 p2))) 1e-
)

Here's another:

(defun corner-p ( p1 p2 p3 )
   (equal 0.0 (cos (- (angle p2 p1) (angle p2 p3))) 1e-
)

And another:

(defun corner-p ( p1 p2 p3 )
   ((lambda ( v ) (equal (caddr (trans p2 0 v)) (caddr (trans p3 0 v)) 1e-) (mapcar '- p1 p2))
)

Posted
There are many ways to approach the task, here is one:

(defun corner-p ( p1 p2 p3 )
   (equal 0.0 (apply '+ (mapcar '* (mapcar '- p3 p2) (mapcar '- p1 p2))) 1e-
)

Here's another:

(defun corner-p ( p1 p2 p3 )
   (equal 0.0 (cos (- (angle p2 p1) (angle p2 p3))) 1e-
)

And another:

(defun corner-p ( p1 p2 p3 )
   ((lambda ( v ) (equal (caddr (trans p2 0 v)) (caddr (trans p3 0 v)) 1e-) (mapcar '- p1 p2))
)

 

Thanks Lee

 

:stop: 1-e8 is the thing that im afraid of.... i assume that (equal a b 1-e8) is the tolerance i asked for, but how can i translate it to degree range(aka limit 80 to 100 degrees)? ?

Posted
Thanks Lee

 

You're welcome.

 

:stop: 1-e8 is the thing that im afraid of.... i assume that (equal a b 1-e8) is the tolerance i asked for, but how can i translate it to degree range(aka limit 80 to 100 degrees)? ?

 

1e-8 (0.00000001) is indeed the tolerance used for each comparison, however, this tolerance will represent different quantities depending on the method used.

 

For example, the first method uses the vector dot product of the two vectors, therefore the tolerance will be a factor of the lengths of the two vectors and the cosine of the angle between them (since a·b = |a||b|cosθ); the tolerance used in the second method will also be a factor of the cosine of the angle between the two vectors (but not dependent on the vector length); finally, in the third method, the tolerance represents the linear distance between point p2 and the projection of point p3 onto the line p1-p2.

Posted
You're welcome.

 

 

 

1e-8 (0.00000001) is indeed the tolerance used for each comparison, however, this tolerance will represent different quantities depending on the method used.

 

For example, the first method uses the vector dot product of the two vectors, therefore the tolerance will be a factor of the lengths of the two vectors and the cosine of the angle between them (since a·b = |a||b|cosθ); the tolerance used in the second method will also be a factor of the cosine of the angle between the two vectors (but not dependent on the vector length); finally, in the third method, the tolerance represents the linear distance between point p2 and the projection of point p3 onto the line p1-p2.

 

First of all, i want to say that i love u Lee !!!

if i ever come to London im sure gonna meet you (if u will)

 

second...continue the interesting relationships ratio....i still cant simplify it to a parameter that say...

 


 (if (and 
   (the following 3 points form a corner) (
   (the corner not exceed minimum of 80 degrees)
   (the corner not exceed maximum of 100 degrees)
     )
   
    (princ "the corner is ok")
    (princ "cant accept that corner due to limit violation")
)

Posted

That's very kind of you to say.

 

Since the cosine function is periodic with roots at pi/2, 3pi/2 etc it suffices to test whether the cosine of the angle between the vectors lies within a given range of the root, e.g.:

(defun corner-p ( p1 p2 p3 tol )
   (equal 0.0 (cos (- (angle p2 p1) (angle p2 p3))) (cos (+ (/ pi 2) tol)))
)

So, for 10 degrees either way:

(corner-p (getpoint) (getpoint) (getpoint) (* pi (/ 10.0 180.0)))

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...