PDA

View Full Version : Vector : a trigonometric problem



Leyder Dylan
07-27-2002, 08:04 AM
Hi,

I'd like to calcul the traject for
my bullet but I've a trigonometric problem
and it's so far for me, about 4 years ...

Here's my example :

http://ibelgique.ifrance.com/Slug-Production/Images/Vector.jpg

I've a vector who begins at X, Y ==> (0,0)
His length is : 10

On the example, if the angle is equal to 0°,
the vector's direction will be X,Y ==> (0,10).

But my question is, where will be the vector
if the angle equals 30° ???

So, I must consider this :

- The angle
- The lenght of my vector

What's the formul for calculating this ?

It's possible to apply this formule
with a example. I'm gonna take this example.

1)

- The anle = 0°
- The vector's lenght = 10

2)

- The angle = 90°
- The vector's lenght = 10
==> In this case, X will be equal to - 10 and Y to 0

Leyder Dylan
07-27-2002, 08:42 AM
Ok, I've found

Thanks ...

07-27-2002, 08:22 PM
Struggling with BASIC trig like this is a sure fire sign that you are NOT ready to do stuff like this.

Leyder Dylan
10-29-2002, 10:29 AM
It's me again.

So, it's works only for 2D but now, I want to use that with 3D.

10 ==> Vector lenght

X = 10 * sin(thetaY)
Y = 0
Z = - 10 * cos(thetaY)

My question is ==> What about Y if Y is not equal to 0 ?

nexusone
10-29-2002, 11:05 AM
3D vector math
http://members.tripod.com/~Paul_Kirby/vector/VLintro.html



Originally posted by Leyder Dylan:
It's me again.

So, it's works only for 2D but now, I want to use that with 3D.

10 ==> Vector lenght

X = 10 * sin(thetaY)
Y = 0
Z = - 10 * cos(thetaY)

My question is ==> What about Y if Y is not equal to 0 ?

Bode
10-29-2002, 12:57 PM
Hi...

I've been using this to calculate the trajectory for a bullet in 3D:

TimeStep += .01 //or whatever incremental amount you want
//velocity is just that…the velocity of your bullet
//X,Y,Z is the starting point of your bullet
//frontVector is where direction vector of where the gun barrel is aimed

Float cosA = cos(Angle * .01745329);
Float sinA = sin(Angle * .01745329);

float distance = cosA * timeStep * velocity;
float height = velocity * sinA * timeStep - 0.5f * 0.8f * timeStep * timeStep;
float newDistance = ((distance / 2.0f) * 0.05f);
float newHeight = (height / 2.0f) * 0.05f;

float newX = (frontVector.x * timeStep) + X;
float newY = newHeight + Y;
float newZ = (frontVector.z * timeStep) + Z;


Bode