Author Topic: How to calculate the nearest distance between two Solid3d objects?  (Read 1771 times)

0 Members and 1 Guest are viewing this topic.

gswang

  • Newt
  • Posts: 117
How to calculate the nearest distance between two Solid3d objects?

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: How to calculate the nearest distance between two Solid3d objects?
« Reply #1 on: June 15, 2014, 06:24:10 PM »
The brute force way would be to get all vertices from all faces/edges from the Brep model and get a vector from each one from one solid and get the scalar length to a vertex of the other solid.

A shorter way would be to get the 2 bounding box faces that face each other then get the vertices that lie on each face and then get the scalar as above, it will at least reduce the iterations a great deal.

If you're really adventurous you could build BSP trees or a similar structure and use those for comparison, any way you cut it it's not a trivial exercise, that may give you some direction to get started though and we can help from there.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

gswang

  • Newt
  • Posts: 117
Re: How to calculate the nearest distance between two Solid3d objects?
« Reply #2 on: June 18, 2014, 03:24:38 AM »
Thank your, MickD!

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: How to calculate the nearest distance between two Solid3d objects?
« Reply #3 on: June 18, 2014, 03:43:19 AM »
no problem, let us know how you go.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

gswang

  • Newt
  • Posts: 117
Re: How to calculate the nearest distance between two Solid3d objects?
« Reply #4 on: July 12, 2014, 08:40:28 AM »
 Need explanation is: I was doing the calculation of 3D pipeline, the original data is the axis of space I two lines,
 first, obtains closest points between two axes by GetClosestPointTo method, result is P0, P1,
 then, create two Solid3d, then get all Face 3D object's surface obtained by Brep,
 finally, get the surface's closest point to P0, P1 by ClosestPointTo method, result is  Pa, Pb,
 then the distance pa to pb is the nearest distance between two Solid3d.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: How to calculate the nearest distance between two Solid3d objects?
« Reply #5 on: July 12, 2014, 07:42:37 PM »
good job!
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien