Code: Select all
http://www.box2d.org/wiki/index.php?title=TestSegment
Code: Select all
b2Vec2 intersectionPoint = (1 - lambda) * segment.p1 + lambda * segment.p2;
To do this tutorial correctly you'll either want to use kudoLib (LÖVE Library)'s vector library or the one that comes with ËNVY (LÖVE Framework).
ËNVY (LÖVE Framework): http://love2d.org/forum/viewtopic.php?f=5&t=172
kudoLib (LÖVE Library) : http://love2d.org/forum/viewtopic.php?f=5&t=160
Once you have either one of them vector libraries, or you have your own that supports doing arithmetic to vectors, you do the following code.
Code: Select all
local hitPosition = (1 - impactTime) * startVector + impactTime * finishVector;