mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
Update GetLineToLine.js
This commit is contained in:
parent
7724dd0076
commit
52f3309ab5
1 changed files with 13 additions and 1 deletions
|
@ -63,7 +63,19 @@ var GetLineToLine = function (line1, line2, isRay, out)
|
|||
if (isRay)
|
||||
{
|
||||
t = (dx1 * (y3 - y1) + dy1 * (x1 - x3)) / (dx2 * dy1 - dy2 * dx1);
|
||||
|
||||
if (dx1 !== 0)
|
||||
{
|
||||
u = (x3 + dx2 * t - x1) / dx1;
|
||||
}
|
||||
else if (dy1 !== 0)
|
||||
{
|
||||
u = (y3 + dy2 * t - y1) / dy1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null; // degenerate line segment
|
||||
}
|
||||
|
||||
// Intersects?
|
||||
if (u < 0 || t < 0 || t > 1)
|
||||
|
|
Loading…
Reference in a new issue