# Math for Finding the distance to the hoop

This is a XML slideshow showing how to find the distance from the turret to the hoop using the distance and angles from the camera to the backboard. if there are errors in my math, please correct me.

file is up to date as of 2/2/12 3:23 PM

finding the distance to the hoop.pdf (229 KB)

finding the distance to the hoop.pdf (229 KB)

I have a question…I can see how you could get the Kinect camera to find the distance to the backboard. However, how did you get theta (the angle of the camera to the backboard)?

I would also think about fixing the camera at a set angle, you get a good range of visibility. Then you can find distance based on where on the screen the target is.

Mostly typos:

Page 10 first equation has the denominators swapped

Page 16 what’s the area calculation for? you can get H directly from sin(90-(theta+s))=H/Q

Page 19 should be sin(90-(theta+s))

Here’s another way to do it:

``````I = 180-o

T = sqrt[R^2 + C^2 - 2*R*C*cos(I)]     (Law of Cosines)

s = asin((R/T)*sin(I))     (Law of Sines)

w = 90-(theta+s)   <-angle between T and Q

H = Q*sin(w)

B = Q*cos(w)

F = sqrt[H^2 + (T-B)^2]
``````

Sorry about those typo’s. Here are the changes. also, my calculations were in deg. i changed them to rad which is what the coding usualy uses. Ether is right about using the law of cosines, I just went over it today and couldn’t remember it before. that was my fault.

we are not using the kinect. we are using the axis camera and ratios to find the distance and angles. however, I wasn’t working on getting the images, i just did the math so I can’t help you there.