PDA

View Full Version : Compare two sets of points



tany0070
2007-03-21, 08:03 AM
hi pple, i need to know if there is any way to compare to points, one directly on top of the other, that are slightly errored due to human error during drawing [what i meant was if one is (1.12345, 23.32144) and the other(1.12349, 45.42321), the error is caused by human error during drawing]. thanks

GreyHippo
2007-03-21, 04:17 PM
What type of object are the two points? Points, Insertion points of a block or intersection of two line segments.

T.Willey
2007-03-21, 04:24 PM
I drew two lines, where one end point of each was the same, then moved one 0.0001 to the right. Then when the call to 'getpoin' I selected the two ends that were one touching.


Command: (EQUAL (GETPOINT) (GETPOINT))
nil

Command: (EQUAL (GETPOINT) (GETPOINT) 0.0001)
nil

Command: (EQUAL (GETPOINT) (GETPOINT) 0.001)
T

Is this what you are looking for?

GreyHippo
2007-03-21, 04:36 PM
See if this works for you



(defun c:comp_pts (/)
(setq pt1 (getpoint "\nPick First Point: "))
(setq pt2 (getpoint "\nPick Second Point: "))
(setq dist (rtos (distance pt1 pt2) 2 8))
(setq del_x (- (nth 0 pt1) (nth 0 pt2)))
(setq del_y (- (nth 1 pt1) (nth 1 pt2)))
(setq del_z (- (nth 2 pt1) (nth 2 pt2)))

(if (and (= del_x 0) (= del_y 0) (= del_z 0))
(setq alertstr "The Two Points are Equal")
(progn
(setq alertstr (strcat "Distance Between Points = " dist "\n"
"Delta X = " (rtos del_x 2 8) "\n"
"Delta Y = " (rtos del_y 2 8) "\n"
"Delta Z = " (rtos del_z 2 8)
))))
(alert alertstr)
(princ)
)
(princ)

T.Willey
2007-03-21, 04:49 PM
boesiii,

One thing I have learned is when measuring numbers with an equal function 'equal' 'eq' or '=' it is bested to use either 'eq' or 'equal' with a fuzz factor. So here

(and (= del_x 0) (= del_y 0) (= del_z 0))
I would use


(and
(equal del_x 0 0.001)
(equal del_y 0 0.001)
(equal del_z 0 0.001)
)

tany0070
2007-03-22, 12:38 AM
thanks. man how in the world did i miss that. *sigh*

GreyHippo
2007-03-22, 12:57 AM
Thanks Willey, I had no idea that function existed.