KernelCAD Documentation

DInsight Home
Skip Navigation Links.
Start page
Quick Start
Installation
Overview of the software
What is new
Collapse KernelCAD ModelsKernelCAD Models
Collapse KernelCAD ComponentsKernelCAD Components
KernelCAD Control
KernelCAD .NET Control
Methods and Properties
Menu
Model Explorer
Birds Eye View
Programming
Direct User Access
Direct Operations
Interface Queries
Printing Support
Data Types
Modes of KernelCAD Control
DIObjectGenerator class
Properties
FlatObjectArray Poperty
Context
64 bit development
Dual Mode
Initialisation Context
Overlay Editor
Memory Management
Input validation
Collapse Advanced functionalityAdvanced functionality
Collapse InterfacesInterfaces
Alphabetical list
I3DGrid
I3DBugger
I3Dpt
IAxiBase
IAxis
IBoolSection
IBoolSectionEx
IBoundary
IColor
IConstraint
IData
IDiffSurface_KC
IDIFont
IDraw
IDrawUtil
IDraw2
IElem
IElement
IKCLine
ILightSource
ILocation
ILocationEx
IMaterial
IMetrics
IMetrics2
IModel
IModel2
IModelEx
IPatch
IKCPathCollisionDetector
IProfiles
IPropertyArray
IPropertyArray2
IStdShape
IStrip
ISurface
IText
ITexture
ITransform
IUnknown
Collapse Open Cascade TechnologyOpen Cascade Technology
Collapse DataData
Collapse MovementMovement
Collapse FramesFrames
Collapse Oriented ObjectsOriented Objects
Collapse SectionsSections
Collapse GeneralGeneral
Collapse Topological InterfacesTopological Interfaces
Collapse Viewing InterfacesViewing Interfaces
Collapse Lines And CurvesLines And Curves
Collapse Symmetry InterfacesSymmetry Interfaces
Collapse Clipping plane interfacesClipping plane interfaces
Collapse AlgorithmsAlgorithms
Collapse 2D Geometry2D Geometry
Collapse Programming Samples and TutorialsProgramming Samples and Tutorials
Collapse OverviewOverview
Collapse DeploymentDeployment
Collapse .NET Samples.NET Samples
Collapse C++ SamplesC++ Samples
Collapse Visual Basic SamplesVisual Basic Samples
Collapse Delphi SamplesDelphi Samples
Collapse 3D Debugger3D Debugger
Collapse DeploymentDeployment
Licensing
Model Viewer
Open C++ Source
Technical Support
Skip Navigation LinksHome Page > Programming Samples and Tutorials > Overview > Collision
Collision Detection

Distances and Collision Detection

Distances between different objects can be calculated with the help of IMetrics interface. IsCloserThan of the same interface is helpful for collision detection during simulation or animation of movements or geometry modifications of an object. Collision sample demonstrates a simple case of such application.

The main issue with programming collision detection is that during the movement simulation the above methods have to be called frequently numerous times and because they apply heavy computational load the process may be slow.  Below are few hints to alleviate the problem.

  • Avoid using includeChildren flag from the contexts structure during the calls to IMetrics.Dist or IsCloserThan methods. and needAllflag during calls to IsCloserThan
  • Choose carefully other parameters from the context structures
  • Complexity of of surface of both objects affect significantly the performance so it is recommended to create surrogate invisible copies of the objects with fewer level of details and detect collision between them instead. It is best to make the surrogate a child of the actual object so they will be moved synchronously.
  • Often is is know in advance which part ob the object can collide with other objects. So the surrogate can be made to represent this part of the object. Clip planes is one good method to extract such part of the object.
  • Further optimization of the process can be done when path of the movement is known beforehand and the problem is to find the moment when and if the collision occur. Contact us if you need assistance with this technique.

See Also: Collision Sample

Path Collision Detection

Path Collision Detection is another, higher level technology in KernelCAD for collision detection. Path Collision Detection assumes that movement of objects is known in advance. This allows further optimization of performance inside KernelCAD component. It is assumed that the objects do  not initially interfere with each other. The result may be incorrect if it is not true. Number of objects which participate on collision detection is not limited

The functionality is provided by KernelCAD Collision Detector. Collision Detector takes a set of sections (objects) along with paths of their movement. Result of the Collision Detection operation is the time moment when the first collision has occurred.

To perform Path Collision Detection:

  1. Create movement one per each object involved in collision detection with IDIObjGenerator.Create(EObjectType.eObjTypeMove).
  2. Query IMove_KC from the return of the above call and modify the movement as described in Movements topic
  3. Create an instance of Collision Detector with a call to IDIObjGenerator.Create with eType parameter set to eObjTypePathCollisionDetector member of the EObjectType enumeration. 
  4. Query IKCPathCollisionDetector interface from the return of  IDIObjGenerator.Create
  5. Query IKinematicSet_KC from the IKCPathCollisionDetector
  6. Use IKinematicSet_KC.AddObject to add objects along with with their movements for detection
  7. Call IKCPathCollisionDetector.Detect to obtain the moments when collision happened
  8. Optional: Call IKinematicSet_KC.SetPosition to display position of objects when the collision occurred
  9. Optional: Call IMetrics.Dist to obtain extended information about nearest points at collision configuration

Note that Path Collision Detection is extremely computation intensive this means that only necessary object should be added for detection and various settings like precision in IKCPathCollisionDetector.Detect call, geometric resolution of the objects and sampling of the movement paths should be set to lowest acceptable values, which can be tuned in after a number of tests.

See Also: Collision Path Sample