Jump to content
  • Advertisement
Sign in to follow this  
Dookie

Quick vector math question...

This topic is 4737 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, here's an easy one. Here's a scenario based on the above picture, and you'll have to forgive me if my math terminology is lousy. I have a line whose normalized vector coordinates are (-0.894, 0.447). I know that this vector passes through Y at the graph coordinates (0, -8). This vector also passes through X, at the graph coordinates (?, 0). I'm trying to figure out how I get an answer to the question mark! Would any of you guys post a formula I can use to get the question mark answered? Thanks in advance for the help, I really appreciate it!

Share this post


Link to post
Share on other sites
Advertisement
The vector describes a direction. Let the components be dx=-0.894, dy=0.447. Starting at a given point P (0, -8), you must add t multiples of dx and dy to get to any other given point Q (?, 0).

So:
Qx = Px + dx * t
Qy = Py + dy * t

You know Px and Py, dx and dy:
Qx = 0 + -0.894 * t = -0.894 * t
Qy = -8 + 0.447 * t

You also know Qy:
0 = -8 + 0.447 * t
8 = 0.447 * t
t = 8 / 0.447

So you can determine Qx:
Qx = -0.894 * 8 / 0.447
Qx = -16

Share this post


Link to post
Share on other sites
An easier way might be as follows:

You have point p0 (0, -8) and point p1 (?, 0). The slope of the line that connects these two points is :


(y1 - y0) (0 - -8)
--------- = --------
(x1 - x0) (? - 0)




You already know the slope of your line from the vector (0.447, -0.894), so now just solve for ? below.


(0 - -8) 0.447
-------- = ------
(? - 0) -0.894

? = -16


Share this post


Link to post
Share on other sites
Cool, thanks for the replies!

I can understand Kippesoep's method, because he posted equasions on how to accomplish what he was describing. But I don't understand ascorbic's method at all, and I'd like to know it too... Exactly how did you get -16 out of what you posted? It's been years since I've attended a geometry class, so even something as simple as 'slope' is hazy to me. If you could step though the process like Kippesoep did, then that would be awesome!

Thanks again!

Share this post


Link to post
Share on other sites
If you understand the equation (y = mx + b) then this equation pretty much solves itself.

m stands for the slope of the vector you are using. Slope is merely the amount your vector changes in the y direction for every 1 unit your vector changes in the x direction. Maybe not so obviously, but your normalized vector is used to determine the slope.

Change in y = 0.447
Change in x = -0.894

m = Change in y / Change in x = 0.447 / -0.894 = -0.5

Now the equation you need to solve reads y = -0.5x + b

You gave us a point (0, -8) that you know is on the line. This is in the form (x, y). Whenever x=0, the y value is called the y-intercept. This is the same as b in the equation we need to solve for. Now substitute for b.

y = -0.5x + (-8)

The other point you gave was (?, 0). I'm changing ? to f, so (f, 0). Once again in the form (x, y), substitute this into the formula. You get:

0 = -0.5f + (-8)

Now solve for f and you get -16.

Share this post


Link to post
Share on other sites
Now THAT makes sense! Thanks for the tutorial, ascorbic. I'll play around with both equasions and see which one works better for me. I'm sure I'll find a use for both ideas.

Thanks again!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!