
find a largest subset of collinear points.
int main()
cout <<
find_maximal_collinear_subset(
read_points(std::cin))
find_maximal_collinear_subset()?
bool collinear(pt, pt, pt)
find maximal collinear subset(points)
max points = { }
for p1 in points
for p2 in points - p1
cpoints = { p1, p2 }
for p3 in points - cpoints
if collinear(p1, p2, p3)
cpoints += { p3 }
if #cpoints > #max points
max points = cpoints
return max points

find maximal collinear subset(points)
max points = { }
for p1 in points
order points by increasing angle
scan for similar angles
similar angles mean collinear points
remember the biggest set
return max points
| This page last modified on 31 January 2006. |
This work is covered by a |