|
A Equation for a Cannon
My team was planning on making cannon during the first week. I thought I'd be cool to make it autonomously shoot. So I made a huge trig/calc function to calculate the specs. Just as I finished it, they decided to go the easy way with some roller thing, nothing fun to program.
So thats my story, and attached is the function. It's long and it's ugly.
It's designed for a rotating cannon of variable velocity. It returns a pair<float , pair<float , float>> of <velocity to shoot , <angle to shoot , enemy's angle>>. The enemy's angle is to determine if the enemy is coming at you and blocking his trailer.
It needs a camera that is tracked to the target trailer. It also needs a rangefinder attached to the camera, preferably with a narrow beam pattern.
It's in c++, but you could change the pairs to structs to make it c.
I'm not sure if it works, I'm not sure if it even compiles. But if anyone is interested I'll help anyone fix it and use it.
|