I am working on a routine (or rather a part of a routine) that figures out whether a text object is inside or outside of a polyline.
I'm doing it by extracting the text's insertion point into a variable (two, actually, x and y points) and the polyline into a list of its vertices.
I then cycle through each vertex in turn, seeing whether the x-value of the text point lies between those of the two points. If it is I can check the y-coordinates, if it's not just pass onto the next point.
The routine I've developed to do this comparison is this:
(DEFUN lessismore ( x y z / )
(IF
(>= x y)
(IF
(<= x z)
1;(PRINC "\nx LIES BETWEEN y AND z")
0;(PRINC "\nx LIES OUTSIDE THE RANGE")
);IF
0;(PRINC "\nx LIES OUTSIDE THE RANGE")
);IF
(PRINC)
)
x, y, and z are the point of the object, and of the first, and second vertex, respectively.
My first test run, the insertion point (x) is 7720.1, the first vertex point (y) is 7723.28, and the second vertex point (z) is 7720.84, i.e. the second vertex is *before* the first.
You and I can easily see that x is indeed within the range, the routine, though, can't, since it it sees the insertion point as being above the frist vertex.
The only way, so far, that I can think of to get round this would require just over twice the amount of code (compare the two vertices, then have two options, either as written above, or as above with the "y"s and "z"s swapped).
Can anybody suggest a cleaner way to do it?
dJE