I seem to have stumbled across a few undefined functions in line2d.h.
intersectWith() calls both getInterSectionOfLines() and isPointBetweenPoints(), neither of which are defined elsewhere in line2d.h, nor anywhere else I can find. I searched the forum for these names and came up with a few posts which mentioning this problem, none of which seemed to have been answered.
Am I missing something?
line2d bugs
I also couldn't find isPointBetweenPoints or getInterSectionOfLines when I searched the forum.
new intersectWith function-
edit: mentioning the offending functions seemed to fix the search index. sweet
edit2: somehow this code is bugged in msvc, but works fine in gcc.
new intersectWith function-
Code: Select all
bool intersectWith(const line2d<T>& l, vector2d<T>& out)
{
bool found=false;
f32 a1,a2,b1,b2;
// calculate slopes, deal with infinity
if (end.X-start.X == 0)
b1 = (f32)1e+10;
else
b1 = (end.Y-start.Y)/(end.X-start.X);
if (l.end.X-l.start.X == 0)
b2 = (f32)1e+10;
else
b2 = (l.end.Y-l.start.Y)/(l.end.X-l.start.X);
// calculate position
a1 = start.Y - b1 * start.X;
a2 = l.start.Y - b2 * l.start.X;
out.X = - (a1-a2)/(b1-b2);
out.Y = a1 + b1*out.X;
// did the lines cross?
if ( (start.X-out.X) *(out.X-end.X) >=0 &&
(l.start.X-out.X)*(out.X-l.end.X)>=0 &&
(start.Y-out.Y) *(out.Y-end.Y) >=0 &&
(l.start.Y-out.Y)*(out.Y-l.end.Y)>=0 )
{
found = true;
}
return (found);
}
edit2: somehow this code is bugged in msvc, but works fine in gcc.