Closest points between two curves

1k views Asked by At

While writing a macro on VBScript to find the nearest two points in given two CATIA surfaces, I am facing some difficulty. It would be great if I could find a pre-defined function of CATIA or an algorithm to do the same.

1

There are 1 answers

1
zipzit On

Not an easy algorithm.

Divide your 3D space into 10 units in the X direction, 10 units in the Y direction, 10 units in the Z direction. You now have a 3D space which contains 1000 little cubes. Analyze each cube in space. Does the surface #1 cross that cube? Does Surface #2 cross that cube? If so, keep a record of that. Each cube of this workspace could have no surfaces crossing, both surfaces crossing or a crossing of either surface #1 or #2.

If any cubes have both surfaces crossing, the next step there.

do the divide by 10 units in each direction again (recursively) and do the analysis again. (etc...)

At some point you will have a 3D space where no subdivided cube has both curves crossing it. Run thru an analysis program to determine the distance between cubes with surface crossing. You should be able to find which two cubes are a minimum distance apart.

Use continued recursion and subdivision to optimize a solution.

Note: if you are using JavaScript, a library like Sylvester.js is REALLY handy for this problem.