# Quick vector math question...

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

## 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 on other sites
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 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 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 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 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!

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11