# Collision Detection Capabilities in 3D Slicer

**URL:** <https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854>\
**Category:** Development\
**Tags:** slicerrt, python\
**Created:** [December 2, 2020, 7:59pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854 "2020-12-02T19:59:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [December 2, 2020, 7:59pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/1 "2020-12-02T19:59:41Z")

</div>

Operating system: Windows 10  
Slicer version: 4.11.2

Hi,

I am working on a project that involves the incorporation of collision detection capabilities, to be applied to neurosurgical robotics applications.

Currently, the project is at its infancy, where I am attempting to model objects of interest in 3D Slicer and to explore collision detection features and capabilities.

I have built a module in Slicer to serve as a basic framework for such exploratory work. It involves the creation and loading of primitive `vtkMRMLModelNode` 3D objects into the scene, meant to simulate a neurosurgical setting (sphere = critical brain anatomy, rod = robotic arm).

The user can manipulate either object in 3D space by reorienting it and modifying its position and size. The module interface is as shown:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/8/78c07d3faa9359c4811d32bed99c9fc9a96fe39b.png)

**The goal is to be able to detect the collision as displayed above in the Slicer scene.**

The question becomes then: are there any existing techniques, tools, libraries/classes, or extensions that could provide collision detection coverage?

Thank you,  
Hikmat

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [December 2, 2020, 9:56pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/2 "2020-12-02T21:56:08Z")

</div>

In the SlicerRT extension there is a module that uses collision detection. The filter doing it, and which you can use for your project is [vtkCollisionDetectionFilter](https://github.com/SlicerRt/SlicerRT/blob/master/SlicerRtCommon/vtkCollisionDetectionFilter.h). There was ongoing work to integrate it in VTK, but I’m not sure if it has been finished. The module using it, and which can serve as an example, is [RoomsEyeView](https://github.com/SlicerRt/SlicerRT/tree/master/RoomsEyeView).

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [March 19, 2021, 9:03pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/3 "2021-03-19T21:03:34Z")

</div>

Thank you very much for the reply and for the examples provided. Work on this project had grinded to a halt due to other competing priorities, but has emerged back to the forefront.

Hence, I would like to pose some follow-up questions:

1. This is somewhat of a sanity check, but my understanding is that the `vtkCollisionDetectionFilter` is not a standalone function, i.e., given that it does not seem to be integrated into VTK, I cannot simply call it as I would for say, model creation (e.g. `vtk.vtkSphereSource`).

2. The scripts and functions comprising the `vtkCollisionDetectionFilter` are written in C++, as was the `RoomsEyeView` example module sourcing it, hence simplifying integration and function calls to collision detection features.

Thank you,  
Hikmat

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 22, 2021, 2:31pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/4 "2021-03-22T14:31:17Z")

</div>

1. Yes it is part of SlicerRT currently. There have been initiatives for integrating it to VTK (see for example [here](https://public.kitware.com/pipermail/vtk-developers/2018-May/036127.html)), but I don’t think it has been finished. You can either use SlicerRT, or you can decide to just copy this filter to your project. It would be cleaner to rely on SlicerRT (maintenance in only one place), but if you do not use anything else from there, then it is understandable if you copy these two files to your own purpose.

2. 

```auto
 import vtkSlicerRtCommonPython
 collisionDetection = vtkSlicerRtCommonPython.vtkCollisionDetectionFilter()

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 23, 2021, 6:09am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/5 "2021-03-23T06:09:39Z")

</div>

> [@cpinter](#):
>
> Yes it is part of SlicerRT currently. There have been initiatives for integrating it to VTK (see for example [here](https://public.kitware.com/pipermail/vtk-developers/2018-May/036127.html)),

`vtk.vtkCollisionDetectionFilter()` is available in recent Slicer Preview Releases.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 23, 2021, 10:32am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/6 "2021-03-23T10:32:53Z")

</div>

@lassoan Good to know, thanks!

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [March 30, 2021, 4:23am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/7 "2021-03-30T04:23:48Z")

</div>

Thank you very much for the reply and for the guidance provided so far.

Indeed, the line of code `import vtkSlicerRtCommonPython` works in the Python Interactor (clean return), provided that I have the SlicerRT extension installed:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/2/f22589f11541fc91aa7c4baca90ae6f84e519f78.png)

However, when I try to include this import line in my script, Slicer is not able to recognize it:

 ![error](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/e/5e21e514cb4bfa398790170d5af0899f1b7e17f7.jpeg)

I tried modifying the import statement in my script to point it to the SlicerRT repo folder cloned in my workspace as follows: `from SlicerRT.SlicerRtCommon import vtkSlicerRtCommonPython`. Yet this gives me the following error:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/d/bd71a22fba628ddcde53c60d5c225ec9aba4876f.png)

How would I be able to make this import in my script?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 30, 2021, 9:12am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/8 "2021-03-30T09:12:01Z")

</div>

As @lassoan pointed out, the filter is available in VTK, simply using `vtk.vtkCollisionDetectionFilter()`.

To answer your question specifically, I suspect that your module is imported before SlicerRT. Try just importing it in the function in which you use it. Also make sure that both SlicerRT and your module are added at the same time (sorry if too trivial but one can miss trivial stuff easily, I know that from experience)

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [March 31, 2021, 1:14am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/9 "2021-03-31T01:14:43Z")

</div>

Thank you for your continual help and guidance. Yes, I did look into @lassoan’s comment regarding the filter being available in VTK. Yet I am not sure if I understood it correctly, because it does not work when I tried running it in the Python Interactor:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/c/fc3b5012d1785145344d2eabe7fd167830676a11.png)

However, the comment was prefaced by this expecting to work in the latest Slicer Preview release (4.13), yet I am on the stable release version (4.11). So perhaps I will have to upgrade and install the latest Slicer Preview release version and test it out there.

As for the import not being picked up by my module, indeed, it most likely has to do with me not being diligent enough with trivial module management. I am not sure if I understand the comment though, regarding adding SlicerRT and my module (Neurosurgical Robotics) at the same time, but this is my current setup:

**Module Script** :  
My imports are listed out at the top of my script as shown below:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/2/4292b57e4a07851c14a1797227863e1718929ea7.png)

**Module Loading Management:**  
I believe I do have it set up such that my module (CollisionDetection) is being imported after SlicerRT. If I understand correctly, this can be verified by the order in which the two modules are listed in the Application Settings → Modules window:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5b8e6c8a76972ab5f4c276cb07895ac4ba02966c.png)

In addition, my module appears to be loaded in after the SlicerRT extension:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/2/92c4086a62d697b15c8f70d9071121cf74bc337b.png)

**Module Directory Workspace**  
I have my directory workspace structured as follows: my module script `CollisionDetectionFramework.py` is contained in the folder `collisionDetection`, with the SlicerRT project cloned and located in the same folder, such that import accesses to the SlicerRT module can be made:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/8/688dcc5412947c04c7bead043b3d3b732071d577.png)

Hopefully this is enough information for you to be able to diagnose the issue here. Thank you.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [March 31, 2021, 9:51am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/10 "2021-03-31T09:51:12Z")

</div>

Yes, definitely use the latest version please.

The line `import SlicerRT.SlicerRtCommon import vtkSlicerRtCommonPython` won’t work. See my above comments about why.

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [April 1, 2021, 4:32am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/11 "2021-04-01T04:32:29Z")

</div>

Thank you so much for the help and guidance so far. I am now able to access the VTK collision detection filter through my module script as well as make function calls to it!

Currently; however, I am trying to figure out the set of function calls I will need to make through the filter to detect collisions between my simplistic VTK model objects.

I have studied the code in the RoomsEyeView module to get a sense of the function calls needed to set up collision detection. My understanding is summarized as follows:

1. Instantiate the VTK collision detection filter
2. Define the models to be passed in as inputs
3. **Set the transforms required**
4. Return the number of contacts detected

Step 3 is where my understanding of the code is weak, given that the SlicerRT environment is much more complicated than mine, with many different models and reference systems. My module is populated with only a sphere and a rod for simulation purposes, and I am not quite sure what transforms I would need to specify or create.

The code block below is what I have tried so far (ignoring the need for setting transforms), and the function call to `GetNumberOfContacts()` causes Slicer 4.13 to crash:

> `collisionDetection = vtk.vtkCollisionDetectionFilter()`  
> `input1 = slicer.mrmlScene.GetFirstNodeByName("Input Model 1")`  
> `input2 = slicer.mrmlScene.GetFirstNodeByName("Input Model 2")`  
> `collisionDetection.SetInputData(0, input1.GetPolyData())`  
> `collisionDetection.SetInputData(1, input2.GetPolyData())`  
> `numContacts = collisionDetection.GetNumberOfContacts()`

My assumption is that this code crashes on me because I have not set the transforms required through `collisionDetection.SetTransform()`, since I do not understand what parameters I would need to pass in or what this function call is doing.

The SlicerRT example seems to set the transforms required by making calls to `SlicerIECTransformLogic` and calling `GetTransformNodeBetween()` between the object model of interest and the reference frame RAS. My understanding here is weak though, since I can’t see why this is necessary or what transforms would be needed.

Hence, my follow-up questions are the following:

1. What transforms would I need to set/pass in to the collision filter (and presumably create beforehand)?
2. The `SlicerIECTransformLogic` routines are a bit intimidating since I don’t fully understand what’s going on. How could I go about creating these transforms or getting the necessary transforms between two frames in a simpler manner?

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [April 2, 2021, 1:28pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/12 "2021-04-02T13:28:20Z")

</div>

> [@Hikmat](#):
>
> What transforms would I need to set/pass in to the collision filter (and presumably create beforehand)?

There are many examples on [VTK site](https://kitware.github.io/vtk-examples/site/Python/Visualization/CollisionDetection/). The collision example has two spheres: sphere0 is moving and it has a transform0 as a transformation data, sphere1 is stationary and it has simple identity matrix.

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [April 6, 2021, 2:57am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/13 "2021-04-06T02:57:35Z")

</div>

Thank you very much for the reply and for the example provided. My case is similar, in that I have a sphere and a cube in the Slicer scene, but they are stationary VTK objects. They can; however, be translated by the user and moved around the scene.

I have tried following the example in how the transforms were set, but I still have Slicer 4.13 crashing on me upon the `GetNumberOfContacts()` function call.

This is what my code looks like so far:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/d/ed54b46dff3e889a34b574454766522a6ddeafb5.png)

The transforms `transform0` and `transform1` are initialized using `vtkTransform()` and are initially set to the centers of the VTK objects using `vtkTransform.Translate()`. As the user moves the objects around, I update the transforms for each object using `vtkTransform.Translate()` to have the transforms fixed to the center of the objects.

I tried printing the output of the collision filter using the `GetOutput()` call for one of my VTK objects, and this is the debug trace I get:

> vtkPolyData (000001E17CFD33F0)  
> Debug: Off  
> Modified Time: 418414  
> Reference Count: 2  
> Registered Events: (none)  
> Information: 000001E1569BECA0  
> Data Released: False  
> Global Release Data: Off  
> UpdateTime: 0  
> Field Data:  
> Debug: Off  
> Modified Time: 418411  
> Reference Count: 1  
> Registered Events: (none)  
> Number Of Arrays: 0  
> Number Of Components: 0  
> Number Of Tuples: 0  
> Number Of Points: 0  
> Number Of Cells: 0  
> Cell Data:  
> Debug: Off  
> Modified Time: 418414  
> Reference Count: 1  
> Registered Events:  
> Registered Observers:  
> vtkObserver (000001E15699F7D0)  
> Event: 33  
> EventName: ModifiedEvent  
> Command: 000001E1569BEAC0  
> Priority: 0  
> Tag: 1  
> Number Of Arrays: 0  
> Number Of Components: 0  
> Number Of Tuples: 0  
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 )  
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )  
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )  
> Scalars: (none)  
> Vectors: (none)  
> Normals: (none)  
> TCoords: (none)  
> Tensors: (none)  
> GlobalIds: (none)  
> PedigreeIds: (none)  
> EdgeFlag: (none)  
> Tangents: (none)  
> RationalWeights: (none)  
> HigherOrderDegrees: (none)  
> Point Data:  
> Debug: Off  
> Modified Time: 418413  
> Reference Count: 1  
> Registered Events:  
> Registered Observers:  
> vtkObserver (000001E15699F710)  
> Event: 33  
> EventName: ModifiedEvent  
> Command: 000001E1569BEAC0  
> Priority: 0  
> Tag: 1  
> Number Of Arrays: 0  
> Number Of Components: 0  
> Number Of Tuples: 0  
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 )  
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )  
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )  
> Scalars: (none)  
> Vectors: (none)  
> Normals: (none)  
> TCoords: (none)  
> Tensors: (none)  
> GlobalIds: (none)  
> PedigreeIds: (none)  
> EdgeFlag: (none)  
> Tangents: (none)  
> RationalWeights: (none)  
> HigherOrderDegrees: (none)  
> Bounds:  
> Xmin,Xmax: (1, -1)  
> Ymin,Ymax: (1, -1)  
> Zmin,Zmax: (1, -1)  
> Compute Time: 0  
> Editable: false  
> Number Of Points: 0  
> Point Coordinates: 0000000000000000  
> PointLocator: 0000000000000000  
> CellLocator: 0000000000000000  
> Number Of Vertices: 0  
> Number Of Lines: 0  
> Number Of Polygons: 0  
> Number Of Triangle Strips: 0  
> Number Of Pieces: 1  
> Piece: -1  
> Ghost Level: 0

Interestingly, it seems that all the values are ‘‘null’’, i.e. no geometrical properties of the VTK object seem to be captured or processed, with most values found to be 0.

I would appreciate any debugging help or insight into this matter. Thank you.

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [April 6, 2021, 4:43am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/14 "2021-04-06T04:43:01Z")

</div>

Do you update transforms and collision filter before calling GetNumberOfContacts method?

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [April 6, 2021, 5:59pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/15 "2021-04-06T17:59:55Z")

</div>

Yes, I do. The transforms are updated as the objects are moved around and upon the click of the ‘‘Detect Collision’’ button below, I then call `onCollisionDetection()` shown above. This then updates the collision filter before calling the `GetNumberOfContacts` method.

This is what my setup looks like, if it helps:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/9/c9bd8b0213bb541ddf805857ec3c959309847ae1.png)

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [April 6, 2021, 7:14pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/16 "2021-04-06T19:14:38Z")

</div>

Did you try to run the VTK example? My suggestion is reproduce step-by-step the VTK example in your code and find what part doesn’t work.

For example part of the test algorithm for [MLC position](https://github.com/SlicerRt/SlicerRT/blob/master/Beams/Logic/vtkSlicerMLCPositionLogic.cxx#L1013-L1132) calculation that uses collision detection.

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [April 9, 2021, 6:24am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/17 "2021-04-09T06:24:10Z")

</div>

Thank you for the suggestion, I was able to reproduce the VTK example step-by-step in my Slicer environment and it indeed worked.

My scenario is a little different than the VTK example; however, in the sense that the user can move the objects around in the Slicer scene. In contrast, the VTK example has the objects a fixed distance apart and then proceeds to move one of the objects in a predetermined manner.

The MLC position example code was very helpful in revealing a step that I was missing, which was updating the collision filter through the `Update()` method.

With this fix, Slicer no longer crashes on me when I call `GetNumberOfContacts()`, but it is not reporting a collision between the objects, i.e. `GetNumberOfContacts()` returns 0 even though I have the objects oriented in a collision.

I suspect it has to do with the way I am setting my transforms, i.e. I am simply translating each transform to the center of its respective object using `Translate()`, and that may be inadequate for the purposes of passing it through the collision filter.

This is what my code look like so far, I would greatly appreciate some debug help:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/d/0d187a4ee8dee8d785854bb620435863e78ae450.png)

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [April 9, 2021, 8:32am UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/18 "2021-04-09T08:32:38Z")

</div>

> [@Hikmat](#):
>
> I suspect it has to do with the way I am setting my transforms, i.e. I am simply translating each transform to the center of its respective object using `Translate()` , and that may be inadequate for the purposes of passing it through the collision filter.

I think you right. You can try to make a gap between your objects, and then use loop to change transform position of one object until it collides with another one. On each iteration of the loop you must update the transform and the collision filter and check number of contacts.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 19, 2021, 1:08pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/19 "2021-04-19T13:08:07Z")

</div>

If you call `GetPolyData()` or `GetMesh()` on a model node then it returns the mesh in the node’s local coordinate system, not transformed into the world coordinate system.

If you only apply linear transforms to your model nodes then you can retrieve that transform from the parent transform node of each model node and set that in the collision detection filter. This way collision detection is performed on the exact same arrangement that you see in the viewers.

---

<div class="post-metadata">

**Author:** ![Hikmat](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@Hikmat](https://discourse.slicer.org/u/Hikmat)\
**Post date:** [May 8, 2021, 6:30pm UTC](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/20 "2021-05-08T18:30:00Z")

</div>

Thank you for your feedback and suggestion!

Yes, this is the crux of the problem, in that I do not know how to extract the transforms from the model nodes so that I can pass them into the collision detection filter.

My application has model nodes being translated across the screen by the user, with the X, Y, and Z center coordinates updated accordingly using `SetCenter()`. How then would I be able to extract the resultant translations or the respective transforms associated with each model node?

The examples that I were provided with on the [VTK site](https://kitware.github.io/vtk-examples/site/Python/Visualization/CollisionDetection/) and which I tried to follow consisted of initializing transforms, and then updating these transforms according to the translations, and then passing them through the filter. Yet there was a disconnect to me in how these transforms were related to or enforceable on the model nodes.

Therefore, what I need help in is figuring out what transforms to pass into the collision filter and how I can go about extracting them. Thank you!

[Next page](https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854.md?page=2)
