Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -7,8 +7,9 @@ immutable struct Figure {
Edge[] edges;
}
bool contains(in Figure poly, in Point p) pure nothrow {
static bool raySegI(in Point p, in Edge edge) pure nothrow {
bool contains(in Figure poly, in Point p) pure nothrow @safe @nogc {
static bool raySegI(in Point p, in Edge edge)
pure nothrow @safe @nogc {
enum double epsilon = 0.00001;
with (edge) {
if (a.y > b.y)
@ -31,7 +32,7 @@ bool contains(in Figure poly, in Point p) pure nothrow {
}
}
return poly.edges.count!(e => raySegI(p, e))() % 2;
return poly.edges.count!(e => raySegI(p, e)) % 2;
}
void main() {
@ -54,6 +55,7 @@ void main() {
{{10.0, 5.0}, { 7.0, 10.0}}, {{ 7.0, 10.0}, { 3.0, 10.0}},
{{ 3.0, 10.0}, { 0.0, 5.0}}, {{ 0.0, 5.0}, { 3.0, 0.0}}]}
];
immutable Point[] testPoints = [{ 5, 5}, {5, 8}, {-10, 5}, {0, 5},
{10, 5}, {8, 5}, { 10, 10}];