# My blog page I wanted a robot that can shoot a ball into a basket (cup). Before I could build my robot, I had to learn how to calculate the yaw (horizontal) angle to the basket, the pitch (vertical) angle to the basket, and the cannon velocity, which is used to calculate the pitch angle.

In summary, here is what I had to do:
 I had to calculate the velocity of NXT robot cannon The velocity is used in calculating the pitch (vertical) angle of the robot cannon to shoot into the target. Next, I used laws of cosines to calculate the yaw (horizontal) angle to triangulate the location of my target. I also used Pythagorean theorem to triangulate the target; but, I think laws of cosines might be better because there will be less checking for target boundary; that is, we'll have fewer "if" conditions when programming the robot. Though, I wanted the robot to shoot a ball into a cup; my friend Alex and I calculated that the required target diameter width is 8.7 inches for 95% accuracy. I realized that when I shoot the ball, there is friction inside the barrel. I wanted to calculate the cannon barrel friction. This way, I can better estimates the angle for my target. 