Jump to content
  • Advertisement
Sign in to follow this  
HexDump

Perp dot product and intersection point between 2 vectors

This topic is 2503 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

I have been reading a blog about the intersection of vectors. In this blog I have found something like this:

v3={vx:v2.p0.x-v1.p0.x, vy:v2.p0.y-v1.p0.y};
var t=perP(v3, v2)/perP(v1, v2);
ip={};
ip.x=v1.p0.x+v1.vx*t;
ip.y=v1.p0.y+v1.vy*t;
function perP(va, vb)
{
pp = va.vx*vb.vy - va.vy*vb.vx;
return pp;
}


This is how they calculate intersection of vector v2 vs v1. The part that I do not understand is the t calculation (that is the fraction on v2 that are the intersection point).

Could anyone explain why the division between the perp products is t? Have been reading some other info, etc... but can't figure it out.

P.D: The full blog post is: http://www.tonypa.pr...tors/tut05.html

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Any source that talks about the "intersection of vectors" is something to go right to the trash can. You don't intersect vectors with each other.

The standard terms in computer graphics are line segment, ray and line. Line segment is defined by two endpoints. Ray and line are both defined by an endpoint and a direction vector. Ray spans infinitely from its starting point towards one direction, while a line spans infinitely into two directions.

The math for computing intersections between these primitives all boil down to the same function - computing the closest point pairs between two lines, and the math is the same for 2D and for 3D. See e.g. MathGeoLib's Line::ClosestPointLineLine for code and reference.

Share this post


Link to post
Share on other sites

Any source that talks about the "intersection of vectors" is something to go right to the trash can. You don't intersect vectors with each other.

The standard terms in computer graphics are line segment, ray and line. Line segment is defined by two endpoints. Ray and line are both defined by an endpoint and a direction vector. Ray spans infinitely from its starting point towards one direction, while a line spans infinitely into two directions.

The math for computing intersections between these primitives all boil down to the same function - computing the closest point pairs between two lines, and the math is the same for 2D and for 3D. See e.g. MathGeoLib's Line::ClosestPointLineLine for code and reference.


Thanks for the help :). Anyway, this reference you have pointed out seems a different way to accomplish the same that the article I posted. Isn't it?.

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!