Physics Range Equation Calculator

Hello,
How would I write the code to calculate the necessary angle given the velocity and gravitational acceleration (9.8m/sec) using the range equation?
Thank you.

How would you do the calculation with paper and pencil?

One place to start is by writing down the equation, and checking with your calculator to see if it gives the right answer.

Don't forget to express angles in radians.

That catches a lot of noobs out.

Natha:
Hello,
How would I write the code to calculate the necessary angle given the velocity and gravitational acceleration (9.8m/sec) using the range equation?
Thank you.

Acceleration is in m/sec/sec not m/sec.

Thank you all very much.
This is how you would write this equation:

Sorry, I mean to write acceleration as m/sec/sec.

Dust off your algebra and solve for theta.

-jim lee

I was hoping to make the arduino solve theta, if I type in the range (R), the acceleration (g), and the initial velocity.
So basically, all I need is to know how to programme arduino to solve for theta.
I hope this helps. I have been using this equation in physics recently, so I know how it works, I was just wondering whether it is possible to programme arduino to solve it.
Thank you.

Coding the Arduino to solve for theta includes the subset of you knowing how to solve for theta.

-jim lee

I think the OP might be looking to have the Arduino solve it numerically.

I suggest you google that. There are better and faster numerical methods, you’ll have to see if any are fast and small enough for the Arduino. Binary search might be OK.

Or y’all really mean solve for theta. I suggest that while you are dusting off your algebra you also dust off your trigonometry.

a7

arcsinus is the inverse function of sinus. When coding you can use asin()

alto777:
I think the OP might be looking to have the Arduino solve it numerically.

Can't imagine why. There's a closed-form solution for theta.

He said he wants the Arduino to solve the equation. I doubt he wants to build a system on a microprocessor that would produce the closed-form algebraic solution. So.

At least I hope that’s not what he is trying to do.

Sry, solving for theta isn’t really a programming problem. A few minutes googling I found two very nice lecturers run through the derivation of an equation very crisply, one had a bow tie and the other was younger and prettier. Both arrived at the same answer.

Or wait. Someone here will not be able to resist doing your work for you.

a7

he said

calculate the necessary angle given the velocity and gravitational acceleration

so to me it's just rewriting op's equation to extract theta and then code that... I'm sure OP can do it.. use requires trying...

alto777:
He said he wants the Arduino to solve the equation. I doubt he wants to build a system on a microprocessor that would produce the closed-form algebraic solution. So.

At least I hope that’s not what he is trying to do.

Perhaps we have a different understanding of the terminology. To me, "solve it numerically" means using iterative numerical methods to solve an equation (at a particular point) that has no closed-form solution, given the numerical input parameters. An example would be just about any partial differential equation.

My point was that OP's equation has a closed-form solution that you can obtain using simple algebra and trig. So, the exercise is to first get that closed-form solution on paper. Then program it in C++ for the target Arduino. After that, you plug in your (range, Vo, g) parameters and the equation spits out theta. That is NOT "solving the equation numerically"; it's simply plug-n-chug using the already-solved equation.

he said as well

I was hoping to make the arduino solve theta, if I type in the range (R), the acceleration (g), and the initial velocity

I guess "solve" used there meant calculate.

for OP to clarify.

@OP. if you have [color=blue]R = 2.a / 5[/color], can you write [color=blue]a[/color] as a function or

R

? if you know how to do that, you know how to do extract theta from your equation above. it's very similar if you know that arc-sinus is the inverse function of sinus

Numerical solution is not restricted to equations with no closed form solution.

The point about algebra and trig has been made. The OP seems to be at a level where he should be figuring this out himself and/or asking for help elsewhere.

Either approach would be fun to try on an Arduino Missile Control System. Both are of some educational value, both would give an answer as good as it could be, given the sort of ideal nature of the original equation.

a7

Hello,
I do know how to solve for theta on paper, using this equation, I just wanted to try to do it on arduino:
I would like a servo motor to move to the angle of theta.
I will type the initial velocity and the acceleration into the code, then I need the arduino to calculate theta, and move a servo to the angle. Yes, this is for a missile launcher!
I hope that helps.
Thank you.

Natha:
Hello,
I would like a servo motor to move to the angle of theta.
I will type the initial velocity and the acceleration into the code, then I need the arduino to calculate theta, and move a servo move to the angle.

Isn't the acceleration (g) constant?

@Nata - I don't think we need help :slight_smile:

The question that was asked to you was: do you know how to extract theta from the equation you gave us?
it's really basic stuff.

as I said above: if you have [color=blue]R = 2.a / 5[/color], can you write [color=blue]a[/color] as a function or

R

? if you know how to do that, you know how to do extract theta from your equation above. it's very similar if you know that arc-sinus is the inverse function of sinus