Jump to content
  • Advertisement
Sign in to follow this  
jds88

Using vectors from points?

This topic is 2584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I'm not really sure how to explain this so here it goes:

Given a point (X, X, X) how would I cast a vector from that point with a variable angle and length? Basically, I'm trying to create a vector from an objects location (such as a vehicle) with a variable angle
and length to compute a trajectory for a rocket.

You can see more of a visual of what I'm trying to do here:
http://imageshack.us/f/510/javdir.jpg/

The initial location is where the player is standing, the destination location is where the rocket is locked on to. Now I'm trying to create the pink up vector to compute the trajectory. If anyone can provide me the
solutions to this and explain a little bit so I can look into it in more depth would be very helpful. I really need help. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Lets say I wanted the pink vector to be 5000 units high with a 65 degree angle:

MyVec = Vector(1, 5000, 1); // X, Y, Z
MyRot = Rotator(65, 1, 1); // Euler angles (Pitch, Yaw, Roll) , Pitch Up/Down, Yaw left/right

Then I would:

MyVec * Rotate(DestLoc, MyRot) ?

Then given that vector I can:

Dist = MyLocation - DestLoc;

And then compute the trajectory from MyVec and Dist? Like I said, I need some in depth answers please so I can learn from more in depth examples. I have a book on vector math but
when it comes to applying the formulas I'm pretty lost. Thanks for your answer and any other help. :)

Share this post


Link to post
Share on other sites
Wait, is this a ballistic rocket (it goes up and down in an arc) or does it fly along a straight line?

if it's ballistic, it's a little more complicated then what you've put so far

If it's going in a straight line, you want to compute the unit vector to get it's direction, and then multiply that by the rockets speed. If you don't know how to computer the unit vector- you take the difference in each z/y/z direction (call these dx, dy, dz), then use these to compute the distance from your guy to the target (pythagoreans theorum... however you spell that- it's sqrt(dx*dx + dy*dy + dz*dz): call this dt), and then you're unit vector components will be <dx/dt, dy/dt, dz/dt> (but first check that dt isn't 0 for zero-divide error).

Share this post


Link to post
Share on other sites
Yeah well basically I'm trying to simulate a Javelin rocket: http://en.wikipedia....light_path..PNG
where the rocket climbs into the air into a straight line and once the rocket reaches a certain altitude it comes crashing down on the target. So basically, givin my reference drawing:

Once the altitude vector is computed (pink) from the targets location, I then compute the desired direction vector (blue) from the distance vector (green) and altitude vector (pink). And what I was thinking
is that the altitude vector is where the rocket will take course once it reaches that point. Anyway thanks for your all the help and anyone else is welcome to post anything else I could use. Thanks! :)

Share this post


Link to post
Share on other sites

Lets say I wanted the pink vector to be 5000 units high with a 65 degree angle:

Angle measured how? From what, to what?
On the picture the pink vector is vertical, is that just a random case of 90 degrees that you picked or is the vector always vertical (or better said perpendicular to the green vector) and the angle means something else? If yes, then what?

I would like to help you, but I still don't understand the assignment :)

Share this post


Link to post
Share on other sites

[quote name='joe.d-s' timestamp='1321392764' post='4884315']
Lets say I wanted the pink vector to be 5000 units high with a 65 degree angle:

Angle measured how? From what, to what?
On the picture the pink vector is vertical, is that just a random case of 90 degrees that you picked or is the vector always vertical (or better said perpendicular to the green vector) and the angle means something else? If yes, then what?

I would like to help you, but I still don't understand the assignment :)
[/quote]

Okay basically lets just forget everything in that image except the pink vector. Given any position A (X, Y, Z) how would I compute the pink vector with a given length and angle? Since your questions made me think, would I have to use point A as the origin, and compute the X , Y, Z axes from point A to compute the pink vector? And the pink vector in the image is at 90 degrees just for reference.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!