Calculate Y Angle in Games Project C++ Code

  • Thread starter Thread starter MstWntd
  • Start date Start date
  • Tags Tags
    Angle
Click For Summary

Homework Help Overview

The discussion revolves around calculating the Y angle for a projectile in a game project using C++ code. The original poster seeks to determine how the Y rotation of an arrow changes over time based on various parameters such as initial velocity, wind, and flight angle.

Discussion Character

  • Exploratory, Assumption checking, Problem interpretation

Approaches and Questions Raised

  • Participants discuss the original poster's attempts to calculate the new Y rotation using sine functions and kinematic equations. There are questions about the definitions of terms like "wind," "area," and "flight angle," as well as the meaning of "Y angle" in this context.

Discussion Status

The discussion is ongoing, with some participants seeking clarification on the original poster's terminology and equations. There is a lack of consensus on the definitions and relevance of certain variables, and the original poster expresses a desire for a more dynamic solution.

Contextual Notes

Participants note that the original poster's equations include terms that may not be relevant to the problem at hand, leading to confusion. There is also a time constraint mentioned, as the original poster needs to finalize the game behavior by a specific deadline.

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
[tex] Y = ((V_{0} T) + (G(T^{2}) ) / 2) + 18sin(F(PI/180))[/tex]

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

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

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 [itex]\pi[/itex], 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.
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
1K
Replies
3
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
2K
Replies
28
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K