title: Converting x/y values from on screen click to ONVIF PTZ pan/tilt values
body: <p>I'm currently tasked with implementing some PTZ actions for an Onvif camera in C#. My camera has 360 degree pan, 220 degree tilt, a 63 degree horizontal FOV, and a 37 degree vertical FOV.</p>
  
  <p>Right now I currently have a video feed in WPF that shows everything within the FOV. I want to be able to center the camera on whichever spot I click. I can easily get the x/y coordinates of my click, but I'm not sure how to convert that meaningfully. </p>
  
  <p>The ONVIF API accepts Pan and Tilt vectors with X and Y between -1 and 1. The only data I can collect about the camera feed is it's current X and Y vector (between -1 and 1), the center of the video feed in X and Y (pixels), and the X and Y of the point I click.</p>
  
  <p>I've tried every calculation I can think of to get a vector for a relative move or absolute. I used the comment from <a href="https://stackoverflow.com/questions/50565359/ptz-for-onvif-ip-camera">this post</a> to calculate the degree delta based on the pixel delta, but the result doesn't even seem close. I used the formulas in <a href="https://stackoverflow.com/questions/44253787/translating-screen-coordinates-x-y-to-camera-pan-and-tilt-angles">this post</a> to get a pan and tilt value, but I'm not quite sure how to use the results in a helpful way.</p>
  
  <p>I've tried getting the distance percentage and applying that to the current position vector and that also didn't work. </p>
  
  <p>I'm guessing that my best bet is finding doing a relative move since finding an absolute vector with just the FOV seems difficult. If anyone has any insight on how I could calculate it without too much trouble it would be greatly appreciated.</p>