Wednesday 15 July 2015

C++ comparing two value to find which is closest to user input value -


I'm looking at internets for a while to find a solution to my problem. The first few back grounds I am writing a program that calculates the catalog trajectory. The user must first type in the distance then by combining the angle angle, I will find out which combination will give the distance which will come closer to the user input. I do not quite know how to compare the variable and the degree To find the combination of velocity, the distance creates the closest distance to a user input. I'm just trying to keep it simple and easy. Apart from this, I am not using any type of array to store the values. I would like it to be done for flying on me inside of the loop. Any suggestions?

Well, the answer depends on the complexity of your trajectory formula. I think that you are not taking fluid mobility or gravitational discrimination into consideration. In fact, what do I think is that you are using a basic parabolic equation ...

That equation can be solved directly by rearranging it. But the thing is, you are sorting for two variables that are really co-dependent. If you allow both angle and velocity to be separated, you get endless solutions, so you have to restrict the 'best' answer to certain criteria (for example, desired angle or desired velocity).

If you have more variables, like lift, drag, spin, event figure, continuous gravity, air pressure and humidity, you will need to employ a mitigation algorithm which is not trivial in the most basic Is one, but slightly unstable, is a neder-mead algorithm.

If this is not helpful enough then you should provide more information about your problem, and will show some code.

No comments:

Post a Comment