# How to get the position and angle of the crosshair?

**URL:** <https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088>\
**Category:** Development\
**Tags:** python\
**Created:** [October 10, 2021, 9:26am UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088 "2021-10-10T09:26:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [October 10, 2021, 9:26am UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/1 "2021-10-10T09:26:21Z")

</div>

How to get the position and angle of the crosshair?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/11c7526ceec6539b5e65e642ee09b84cad00b961.jpeg)

I try to `crosshair = slicer.util.getNode('Crosshair') `  
and `print(crosshair)`,get those :

```auto
vtkMRMLCrosshairNode (0x7fea623dbca0)
  ID: vtkMRMLCrosshairNodedefault
  ClassName: vtkMRMLCrosshairNode
  Name: Crosshair
  Debug: false
  MTime: 17590155
  Description: (none)
  SingletonTag: default
  HideFromEditors: true
  Selectable: true
  Selected: false
  UndoEnabled: false
  CrosshairMode: NoCrosshair
  CrosshairBehavior: CenteredJumpSlice
  CrosshairThickness: Thick
  CrosshairRAS: [-3.89054, -24.6428, 202.575]
  FastPick3D: false

```

There is no information about angle…

@lassoan@Juicy@jamesobutler @jcfr @pieper

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [October 10, 2021, 10:40am UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/2 "2021-10-10T10:40:36Z")

</div>

这个似乎不是crosshair的问题…应该是返回"the orthogonal nodes around the common [intersection point](https://github.com/SlicerHeart/SlicerHeart/blob/master/ValveView/ValveView.py)"的位置和角度问题…  
我用` sliceToRAS = slicer.mrmlScene.GetNodeByID(sliceNodeId).GetSliceToRAS()`得到了4x4martix, 怎么能够利用该变量, Set the slice to ras呢?

> This does not seem to be a **crosshair** problem… It should be a problem of the position and angle of returning “ **the orthogonal nodes around the common intersection point** ”… I used sliceToRAS = slicer.mrmlScene.GetNodeByID(sliceNodeId).GetSliceToRAS() to get 4x4martix, how can I use this Variables, howto Set the slice to ras?

---

<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:** [October 10, 2021, 12:06pm UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/3 "2021-10-10T12:06:35Z")

</div>

The crosshair only stores position and the current core node ID. If you current view is a slice node then you can get the orientation of that slice from the SliceToRAS matrix.

What are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [October 10, 2021, 12:27pm UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/4 "2021-10-10T12:27:45Z")

</div>

I tried to get the slicenormal form [def getPlaneIntersectionPoint](https://github.com/SlicerHeart/SlicerHeart/blob/master/ValveView/ValveView.py), and then [Set slice position and orientation from a normal vector and position](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#set-slice-position-and-orientation-from-a-normal-vector-and-position).  
but I haven’t got the slicenormal yet…do you help me?

---

<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:** [October 10, 2021, 12:48pm UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/5 "2021-10-10T12:48:13Z")

</div>

Slice normal is the third column of the SliceToRAS matrix.

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [October 10, 2021, 8:48pm UTC](https://discourse.slicer.org/t/how-to-get-the-position-and-angle-of-the-crosshair/20088/6 "2021-10-10T20:48:21Z")

</div>

yes, I’ve got sliceposition and slicenormal from the [def getPlaneIntersectionPoint](https://github.com/SlicerHeart/SlicerHeart/blob/master/ValveView/ValveView.py) through `return x,n1,n2,n3`, and then [Set slice position and orientation from a normal vector and position](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#set-slice-position-and-orientation-from-a-normal-vector-and-position).

谢谢老师
