#get the angle of motion

1 messages · Page 1 of 1 (latest)

oak cloud
#

Putting this in a thread since there's another discussion happening.

#

This is a fairly simple diagram of the situation (simplified to 2d, but that doesn't really change anything)

#

If you know trigonometry, you should be able to easily get the angle required

#

@lone hawk

lone hawk
#

But bro it is calculating the parabolic path of my grenade so how im supposed to know my path like this , i have tried everything from projectile motion r = u^2 sin 2theta/ G

#

But i need to angle

#

To put it in the sin 2 (theta)

#

Idk how to do it

oak cloud
lone hawk
#

How am i supposed to use it in a equation?

oak cloud
#

Using trig, cos (theta) = adjacent / hypotenuse

#

So cos(theta) = velocity / (horizontal velocity component)

#

So theta = inverse cos of (velocity / horizontal velocity)

#

Have you learnt trigonometry in the past? Just curious

lone hawk
#

Yes

oak cloud
lone hawk
#

It is just not much helping to me with text, i understand by listening not reading 🥲

#

Do you have video tutorial for this ?

oak cloud
#

Not really, to be honest

lone hawk
#

Dem

oak cloud
#

It seems like it should be just straightforward trigonometry

lone hawk
#

Yea but looks like I've to take help from AI so that it'll simplify it to me with context

oak cloud
#

But I can try explain it in a different way/draw more diagrams if those help at all

lone hawk
#

Yea they'll help

oak cloud
lone hawk
#

I'll show u what it said , how's that look to u?

oak cloud
lone hawk
#

Yes sir

oak cloud
#

It should be a problem similar to ones you would encounter often in physics, the trick is just to be able to see it as

#

Have you worked with projectile motion where you get a setup like this?

#

If you can combine your linearVelocity.x and linearVelocity.z (using pythagoras' theorem, a^2 + b^2 = c^2), then that value will be your Vx in the diagram


#

Then you can find the value of V, which is linearVelocity.magnitude


#

Now you have all 3 sides of the triangle:

V: linearVelocity.magnitude

Vy: linearVelocity.y

Vx: Mathf.Sqrt(linearVelocity.x * linearVelocity.x + linearVelocity.z * linearVelocity.z)

#

So you can pick any two of them to get the angle (from the horizontal), which you would use in your projectile motion formula

lone hawk
lone hawk
#

How this system is actually working , like it is making path of my grenade (before throwing ), but how it can guess where my grenade is gonna land or go

#

Is there any way so that i can get the angle from where im throwing it like to suppose my 0° (theta)?

oak cloud
#

You shouldn't need to know where it will land to be able to map out the path

oak cloud
#

In 3 dimensions you just add one more, the z component

#

In unity this is linearVelocity.x, linearVelocity.y, linearVelocity.z

#

But in this case we can pretend it's in two dimensions, as if we are looking at the path directly from the side

#

In which case the horizontal component (the "x" component in 2d) will be made of the Z and X components, in the same way that the whole velocity is made of X, Y and Z

#

The magnitude of which can be found from pythagoras' theorem (a^2 + b^2 = c^2)

#

So we can use the magnitude of either the horizontal or vertical component of the velocity, and the magnitude of the velocity, as the side lengths of a triangle to find the angle

#

In the end I think (I may make a mistake in the syntax, I haven't spent any time checking), you should be able to get the angle with:
float angle = Mathf.Asin(linearVelocity.y/linearVelocity.magnitude)

#

Where linear velocity is the object's velocity

#

I realised I was making it a bit more complicated with the whole turning x and z into another vector part, it's not exactly necessary since you can just use the y component

#

I haven't verified but this video: https://www.youtube.com/watch?v=1eRimU5befo

In this video you will understand how to solve All tough projectile motion question, either it's from IAL or GCE Edexcel, Cambridge, AQA, JEE or ANY examinations. The advance level question worksheet video will be uploaded as soon as I am done editing.

For MCQ questions look at this link here:
https://www.youtube.com/@ThatPhysicsGuy/community...

â–¶ Play video
#

might be helpful for explaining projectile motion

lone hawk
#

thank you so much buddy i understood , i just want to know that this float angle = Mathf.Asin(linearVelocity.y/linearVelocity.magnitude) will give me the angle by which my object is going , right?
and then i can use this with my line renderer to show the path to my player like in pubg , right?

oak cloud
#

I’m like 99% sure that should work

#

I don’t know what line rendering system you’re using/making, but it needs to be able to take an initial angle and draw the full curve from I

#

Also, since I’m guessing you want the line to appear before the object is thrown, you can just check what velocity you will give the object and use that for the calculation

#

Anyway, best of luck for getting it all made!

lone hawk
#

v += Physics.gravity * stepTime;//stepTime = 0.05f, v is vector 3
pos += v * stepTime;//stepTime = 0.05f, v = vector3, grenade pos = pos here

bro what does this means ? i cant understand why and how it is done and what its work