Calculate Y Angle in Games Project C++ Code

  • Thread starter Thread starter MstWntd
  • Start date Start date
  • Tags Tags
    Angle
AI Thread Summary
The discussion revolves around calculating the new Y angle for an arrow's projectile motion in a C++ game project. The user provides code snippets for position and velocity calculations but struggles to derive the correct equations for the Y rotation over time. Clarifications are sought regarding variables such as wind, area, and flight angle, with confusion about their relevance in the equations. The user expresses a desire for a more dynamic solution rather than a simplistic approach to achieve realistic arrow behavior. The conversation highlights the need for clearer definitions and a better understanding of the physics involved in projectile motion.
MstWntd
Messages
7
Reaction score
0

Homework Statement



Hi All,

I have this code for my Games Project to calculate the Projectile maths for an arrow

[C++]
mPosition.y = ((pmVolYint * pmTime) + (pmAcc * (pmTime * pmTime) ) / 2) + 18 * sin(pmFAngle*(PI/180));
mPosition.x = ((pmVolYint * pmTime) +
((0.065* pmWind * pmArea) * (pmTime * pmTime) ) / 2) + 18 * cos(pmFAngle*(PI/180));

mVelocity.z = 0.065 * pmWind * pmArea * pmTime + pmVol;
pmTime += pmTimeInc;
[/C++]


What I would lik to do is calculate the new Y (Up/Down) roation produced over time pmTime.

Homework Equations



I don't have any :blushing:


The Attempt at a Solution



mRotation.y = 18 * sin(pmFAngle*(PI/180));

and

mRotation.z = (pmAcc * (pmTime * pmTime) ) / 2) + 18 * sin(pmFAngle*(PI/180));

Please do help and any help is greatly appriecated.

Thanks.
 
Physics news on Phys.org
This isn't a home question..I just put it in here because its so basic..but in order to get my arrow to tilt as it moves I really need its new Angle..someone help!
 
Is there something wrong in my post?

I have to get the behavoir of my game right by 3pm Thursday and I still have to do the documentation!

Please help me out on this :rolleyes:
 
MstWntd said:
Is there something wrong in my post?
I don't think many people here want to try to interpret computer code. Sorry.
 
oh, its same as a maths equation, i think. I'll change it :)

T= Time traveled
W = Wind
A = Area
F = Flight Angle
V= Volicity of Y
G = is the gravity
PI = pie
<br /> Y = ((V_{0} T) + (G(T^{2}) ) / 2) + 18sin(F(PI/180))<br />

T= Time traveled
W = Wind
A = Area
F = Flight Angle
V= Volicity of Y
PI = pie

<br /> X = ((V_{0} T) +<br /> ((0.065 W A)(T^{2}) / 2) + 18cos(F(PI/180));<br />

Ok, so yeah, how will i calculate the new X and Y angle as the arrow is flow over time?
 
I'm sorry. I still don't follow.

From your overall setup, I would assume:
- "time travelled" is like the number of ticks on a clock that occur after the arrow is shot.
- "volicity of y" is velocity in y-direction?
- "gravity" is the acceleration due to gravity (i.e. 9.8 m/s^2)
- "pie" is \pi, the ratio of circumference to diamater of a circle (and actually spelt as "PI", :>)
Does this look correct?

Please explain what you mean by:
- "wind" (is this a force or pressure?)
- "area" (area of what?)
- "flight angle" (I have no idea)
- "X" and "Y" - they look like Cartesian coordinates, but you are calling them angles ...?

The first part of the expressions for X and Y look like ordinary kinematic equations, but I don't understand the trig parts.
 
Sorry, X and Y are indeed Cartesian coordinates.

wind and area are not a factor.

flight angle, is the inital Y angle.

I would know less then you about the equations used here, i ripped it off an example i found. :shy:

at the moment I am calculating the maxhight of the arrow and after it reachers that, i negate the current Y angle.

cheap hack, but yeah has the same effect in the end, however i wud rather have it more dynamic :)
 
MstWntd said:
wind and area are not a factor.
Then why did you put them in your equations? We either need to understand what you mean by "A" and "W" (mmm, root beer), or you need to try some different equations.



MstWntd said:
flight angle, is the inital Y angle.
What is a "Y angle"?



MstWntd said:
cheap hack, but yeah has the same effect in the end, however i wud rather have it more dynamic
Huh? What effect? More dynamic than what? I should tell you that I still have no idea what we're talking about.
 
Back
Top