Ray-casting algorithm: Difference between revisions

Updated D code
(Factor solution)
(Updated D code)
Line 469:
 
=={{header|D}}==
<lang d>import std.stdio, std.math, std.algorithm, std.conv;
 
immutable struct Point { double x, y; }
immutable struct Edge { Point a, b; } // Figure edge from a to b
immutable struct Figure {
string name;
Edge[] edges;
}
immutable struct Edge { Point a, b; } // Figure edge from a to b
immutable struct Point { double x, y; }
 
bool contains(in Figure poly, in Point p) pure nothrow {
Line 502:
}
 
return count!((e){return => raySegI(p, e);})(cast()poly.edges) % 2;
// cast() workaround
return count!((e){return raySegI(p,e);})(cast()poly.edges) % 2;
}
 
Anonymous user