# Method to generate vector using camera location as origin from mouse click

**URL:** https://discourse.vtk.org/t/method-to-generate-vector-using-camera-location-as-origin-from-mouse-click/7943
**Category:** Support
**Created:** [March 1, 2022, 3:11am UTC](https://discourse.vtk.org/t/method-to-generate-vector-using-camera-location-as-origin-from-mouse-click/7943 "2022-03-01T03:11:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Yavol\_Foxxen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yavol_foxxen/32/4769_2.png) [@Yavol\_Foxxen](https://discourse.vtk.org/u/Yavol_Foxxen)
#### Post date: [March 1, 2022, 3:11am UTC](https://discourse.vtk.org/t/method-to-generate-vector-using-camera-location-as-origin-from-mouse-click/7943/1 "2022-03-01T03:11:09Z")

</div>

i am familiar with getting camera position in world.(x,y,z) but getting (i,j,k) vector based on mouse click evades me. trying to be able to click on an arbitrary point on a sphere defined with a center and a radius. the math to find out if a vector intersects exists, as does the formula for finding the vector/sphere intersect point(s). (point closest to camera can be determined by selecting the point with least distance to the camera using the 3d distance formula)

problem is that i can’t figure out how to get the vector from a mouse click to fill in the blanks of the equations to complete my task. any help would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![Yavol\_Foxxen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yavol_foxxen/32/4769_2.png) [@Yavol\_Foxxen](https://discourse.vtk.org/u/Yavol_Foxxen)
#### Post date: [March 2, 2022, 6:06am UTC](https://discourse.vtk.org/t/method-to-generate-vector-using-camera-location-as-origin-from-mouse-click/7943/2 "2022-03-02T06:06:21Z")

</div>

ended up using cell type to get the x,y,z cords of a ray hitting a surface. did the needful
