I've been futzing around with a piece of code that works, but I'm hoping there is a more elegant way to do they following.
I've got a graphical application with four basic items. - a single point object - a two point object (line segment) - a three point object (arc) - a multi point object (polygon) The user can select any two items and have the system calculate the distance between them. Each type of comparison has its own function so the code looks something like this (all of the type casting has been removed to make the code a little cleaner) A = object 1 B = object 2 lfDistance := SOME_WEIRD_CONSTANT; if ((A.Points = 1) and (B.Points = 1)) then lfDistance := geo.Distance(A.P1, B.P1); if ((A.Points = 1) and (B.Points = 2)) then lfDistance := geo.Distance(A.P1, B.P1, B.P2); if ((A.Points = 1) and (B.Points = 3)) then lfDistance := geo.Distance(A.P1, B.PC, B.P1, B.P2); if ((A.Points = 1) and (B.Points > 3)) then lfDistance := geo.Distance(A.P1, B); if ((A.Points = 2) and (B.Points = 1)) then lfDistance := geo.Distance(B.P1, A.P1, A.P2); if ((A.Points = 2) and (B.Points = 2)) then lfDistance := geo.Distance(A.P1, A.P2, B.P1, B.P2); ... and so one for every permutation if (lfDistance <> SOME_WEIRD_CONSTANT) then // Display the distance If there a better way to do this kind of comparison? Thanks for any ideas or opinions, Scott __________________________________________________ Delphi-Talk mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi-talk
