24.12.2019 • C3D Modeler

# Calculating Distances between Bodies with C3D Modeler

Today we want to focus on one of C3D Modeler’s geometric calculation functions. Along with its ability to build and edit three-dimensional models, C3D Modeler supports a variety of calculations with models. Examples include finding surface areas, performing volume and mass-inertia calculations, constructing triangulations and graphical projections, and finding intersections of and distances between bodies.

One of the most common calculations by advanced CAD systems is to check whether assembly components are intersecting. To determine this in your code, we recommend that you use the ::IsSolidsIntersection() method. For the input parameters, set bodies with their matrices of transformation to the global coordinate system. The results from the algorithm are controlled through auxiliary flags:

• checkTouchPoints -- finds points where shells touch
• checkTangent -- determines whether to consider touch points as intersections

While this method establishes whether intersections exist, it does not determine distances between bodies. For this, we provide two more methods, ::MinimumSolidsDistance() and MbFaceShell::DistanceToShell() .

• ::MinimumSolidDistance() -- considers bodies in their local coordinate systems; together with the bodies, it is necessary to specify the transformation matrix into the global coordinate system.
• MbFaceShell::DistanceToShell() -- assumes that the bodies are in the same coordinate system

Calculating the distance between bodies

When searching for intersections within an assembly consisting of large numbers of components, you may find yourself calling these functions repeatedly for the same bodies. In this case, we recommend that you use the first method, since it implements a mechanism for creating and storing objects of tracking bodies and their faces. It is available by setting the corresponding flags isMultipleUseSolid1 and isMultipleUseSolid2.

You find the full list of parameters and their description in our online documentation at
https://c3d.ascon.net/doc/math/group___algorithms__3_d.html

All data about minimum distances are contained in the fields of the MbShellsDistanceData class. It stores not just the values of the minimum distances, but also the indices of the faces and edges of the shells containing the nearest points. In the case of intersections or touching bodies, the output data array MbShellsDistanceData consists of one element with a distance value of "0".

You get data from these fields using class methods. For a complete list of the methods, see the online documentation at
https://c3d.ascon.net/doc/math/class_mb_shells_distance_data.html

Developers understand the importance that speed plays in performing calculations on geometric models, and so we optimized the algorithm for calculating minimum distances in the new release of C3D Modeler. We achieved the higher speeds through data caching and preliminary analysis of the overall cubes of bodies, among other tactics.

Author
Sergey Biryukov
C3D Toolkit product manager
Share