-
Jan 12th, 2018, 03:32 PM
#1
Thread Starter
Member
Physics help!
Hello
I wanna make a program that calculates maximum height, horizontal range, time of flight, and the time of maximum height, and this is called projectile motion, I wanna the codes of equations to calculate these things with two given data which are primary speed and the angel. It is possible because I saw someone who made it with these things but it's arabic
-
Jan 12th, 2018, 10:54 PM
#2
Re: Physics help!
Yes it is possible, but it's not really for us to do your homework for you. How about you put some thought into it, use what you have learned in class, make an effort and then post back when you encounter an actual issue? There are plenty of people here who are willing to help but just doing it for you is not helping; it's doing it for you. Also, you say that you want code but you have posted this in the maths forum. If you are looking to write code in a particular language then you should post in the forum for that language. The maths forum is about mathematical formulae and how to use them, but I'm fairly sure that you can easily find the appropriate mathematical formulae for those calculations. If you want help implementing those formulae in a particular programming language then we'd at least have to know what that language is. Still, if we see no effort at all on your part, most people aren't going to just do your work for you. If you're not prepared to put any effort into this on your own behalf, why should we? Make some effort and you'll find plenty of people who will do so too.
-
Jan 13th, 2018, 04:40 AM
#3
Re: Physics help!
maximum height, horizontal range, time of flight, and the time of maximum height
These are standard projectile equations (assuming constant mass and g). Any advanced level maths book will have them. They are derived from the standard linear equations of motion.
v = u + at
v2 = u2 + 2as
s = ut + 1/2 at2
(note v2 means v squared etc)
A quick internet search will provide plenty of sites explaining projectile motion.
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jan 13th, 2018, 06:51 AM
#4
Thread Starter
Member
Re: Physics help!
here is my code;
Const Gravity = 9.8
Dim Angel As Double
Dim initialvelocity As Double
Angel = Val(txtAngel.Text)
initialvelocity = (txtInitialVelocity.Text)
Dim angelradian As Double
angelradian = Angel * 2 * Math.PI / 360
Dim horizontalrange As Double
horizontalrange = 2 * Math.Cos(angelradian) * initialvelocity * initialvelocity * Math.Sin(angelradian) / Gravity
Dim maximumheight As Double
maximumheight = initialvelocity * initialvelocity * Math.Sin(agnelradian) * Math.Sin(angelradian) / 2 * Gravity
Dim timeofflight As Double
timeofflight = 2 * Math.Sin(angelradian) * initialvelocity / Gravity
Dim timeofmaximumheight As Double
timeofmaximumheight = timeofflight / 2
txtAngelRadian.Text = Str(angelradian)
txtHorizontalRange.Text = Str(horizontalrange)
txtMaximumHeight.Text = Str(maximumheight)
txtTimeOfFlight.Text = Str(timeofflight)
txtTimeOfMaximumHeight.Text = Str(timeofmaximumheight)
but maximum height is bugged, it doesn't calculate the equations, it gives zero
-
Jan 13th, 2018, 07:19 AM
#5
Re: Physics help!
range is (v * v * sin(2 * a)) / g
max height is (v * v * sin(a) * sin(a)) / (2 * g)
time flight is (2 * v * sin(a)) / g
time max height is (v * sin(a)) / g which is (time flight) / 2
so
Code:
maximumheight = initialvelocity * initialvelocity * Math.Sin(agnelradian) * Math.Sin(angelradian) / (2 * Gravity)
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jan 13th, 2018, 07:23 AM
#6
Re: Physics help!
Code:
angelradian = Angel * 2 * Math.PI / 360
which simplies to
Code:
angelradian = Angel * Math.PI / 180
Code:
horizontalrange = 2 * Math.Cos(angelradian) * initialvelocity * initialvelocity * Math.Sin(angelradian) / Gravity
2 * cos(a) * sin(a) is sin(2 * a)
so
Code:
horizontalrange = initialvelocity * initialvelocity * Math.Sin(2 * angelradian) / Gravity
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jan 13th, 2018, 07:25 AM
#7
Thread Starter
Member
Re: Physics help!
I know these rules, but it still gives zero -_-
-
Jan 13th, 2018, 07:27 AM
#8
Re: Physics help!
See my code in post #5, You have missing brackets highlighted in red.
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jan 13th, 2018, 07:29 AM
#9
Thread Starter
Member
Re: Physics help!
I saw them and I changed it but it still give zero
-
Jan 13th, 2018, 07:36 AM
#10
Re: Physics help!
I'm not a VB programmer, but are you getting integer division truncation?
Mathematically,
Code:
angelradian = Angel * Math.PI / 180
is equivalent to
Code:
angelradian = Angel * 2 * Math.PI / 360
so both should provide the same result.
Does
Code:
angelradian = Angel * Math.PI / 180.0
produce the correct value of angelradian?
You also have a spelling error
Code:
maximumheight = initialvelocity * initialvelocity * Math.Sin(angelradian) * Math.Sin(angelradian) / (2 * Gravity)
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jan 13th, 2018, 07:43 AM
#11
Thread Starter
Member
Re: Physics help!
The first rule was my bad, I forgot to change 360 to 180, and the second one now it works, thanks dude.
-
Jan 13th, 2018, 07:54 AM
#12
Re: Physics help!
No problem. Pleased I could help
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|