Vector operation

Started by
3 comments, last by apatriarca 13 years, 2 months ago
Hi guys,

I'd have to resolve this:

| P + V*t | = d

where P and V are 2D vectors, and 't' and 'd' are scalar values. Is it possible to isolate 't' ?
I founded out that t = (d*d - P*P) / V*V is wrong.

How could I resolve ?


THANKS A LOT

-NiG
Advertisement
Assuming P and V are column vectors (if they are row vectors, just change transpose for no transpose, and vice versa), you can rewrite the equation as follows by using vector notation, squaring both sides and expanding to a polynomial of t:

| P + V*t | = d
(P + V*t)[sup]T[/sup] * (P + V*t) = d[sup]2[/sup]
P[sup]T[/sup]*P + 2*P[sup]T[/sup]*V*t + V[sup]T[/sup]*V*t[sup]2[/sup] = d[sup]2[/sup]

Here you have a regular second degree polynomial of t. You can solve this using the standard quadratic polynomial solution. You will have two solutions though, one positive and one negative, and you have to determine which one is correct in your particular context (if not both are acceptable, of course).
Just adding to myself a bit. The two roots you get does not have to be a positive and a negative one. They can have any combination of signs, or even be complex roots. I just failed a bit at geometrically visualizing the problem in my head.

Just adding to myself a bit. The two roots you get does not have to be a positive and a negative one. They can have any combination of signs, or even be complex roots. I just failed a bit at geometrically visualizing the problem in my head.



You're perfectly correct ! It works.
Thanks, I didn't notice one can do that because I was reasoning in another way, without thinking about the dot product.

I'm working on a simple 2D circle collision system (funnily enough, last year I wrote a way way more complex 3D ellipsoidal collision system), so if I happen to have another question, I'll put it here ;)

THANK again man,
bye,

-NiG
It's the intersection between a ray and the sphere centered at the origin with radius sqrt(d).

This topic is closed to new replies.

Advertisement