planed

Undocumented in source.
alias planed = Plane!double

Examples

Plane intersection tests

void testR(planed p, ray3d r, bool shouldIntersect, double expectedDistance, vec3d expectedPoint = vec3d.init) pure nothrow @nogc
{
    vec3d point;
    double distance;
    assert(r.intersect(p, point, distance) == shouldIntersect);
    assert(approxEqual(distance, expectedDistance));
    if (shouldIntersect)
        assert(approxEqual(point.v[], expectedPoint.v[]));
}
// ray facing plane
testR(planed(vec4d(1.0, 0.0, 0.0, 1.0)), ray3d(vec3d(2.0, 3.0, 4.0), vec3d(-1.0, 0.0, 0.0)),
    true, 1.0, vec3d(1.0, 3.0, 4.0));
testR(planed(vec4d(1.0, 1.0, 1.0, -sqrt(3.0))), ray3d(vec3d(1.0, 1.0, 1.0), vec3d(-1.0, -1.0, -1.0).normalized()),
    true, 2.0*sqrt(3.0), vec3d(-1.0, -1.0, -1.0));
// ray facing away
testR(planed(vec4d(1.0, 0.0, 0.0, 1.0)), ray3d(vec3d(2.0, 3.0, 4.0), vec3d(1.0, 0.0, 0.0)),
    false, -1.0);
testR(planed(vec4d(1.0, 0.0, 0.0, 5.0)), ray3d(vec3d(2.0, 3.0, 4.0), vec3d(-1.0, 0.0, 0.0)),
    false, -3.0);
// ray parallel
testR(planed(vec4d(0.0, 0.0, 1.0, 1.0)), ray3d(vec3d(1.0, 2.0, 3.0), vec3d(1.0, 0.0, 0.0)),
    false, double.infinity);

void testS(planed p, seg3d s, bool shouldIntersect, double expectedProgress, vec3d expectedPoint = vec3d.init) pure nothrow @nogc
{
    vec3d point;
    double progress;
    assert(s.intersect(p, point, progress) == shouldIntersect);
    assert(approxEqual(progress, expectedProgress));
    if (shouldIntersect)
        assert(approxEqual(point.v[], expectedPoint.v[]));
}
// segment crossing plane
testS(planed(vec4d(1.0, 0.0, 0.0, 2.0)), seg3d(vec3d(1.0, 2.0, 3.0), vec3d(3.0, 4.0, 5.0)),
    true, 0.5, vec3d(2.0, 3.0, 4.0));
// segment too short
testS(planed(vec4d(1.0, 0.0, 0.0, 0.0)), seg3d(vec3d(1.0, 2.0, 3.0), vec3d(3.0, 4.0, 5.0)),
    false, -0.5);

Meta