public void ComputeCorners_Frustum() { var hull = new Hull3d(new[] { new Plane3d(new V3d(0, 0, -1), V3d.OOO), new Plane3d(new V3d(0, 0, +1), new V3d(0, 0, 0.25)), new Plane3d(new V3d(-1, 0, +1).Normalized, V3d.OOO), new Plane3d(new V3d(+1, 0, +1).Normalized, V3d.IOO), new Plane3d(new V3d(0, -1, +1).Normalized, V3d.OOO), new Plane3d(new V3d(0, +1, +1).Normalized, V3d.OIO), }); var expectedCorners = new [] { V3d.OOO, V3d.IOO, V3d.IIO, V3d.OIO, new V3d(0.25, 0.25, 0.25), new V3d(0.75, 0.25, 0.25), new V3d(0.75, 0.75, 0.25), new V3d(0.25, 0.75, 0.25), }; var corners = hull.ComputeCorners(); Assert.IsTrue(corners.SetEquals(expectedCorners)); }
public static Box3d IntersectionBounds(this Hull3d hull, Box3d box) { if (box.IsInvalid) { return(box); } var bh = Hull3d.Create(box); var pp = new Plane3d[6 + hull.PlaneCount]; bh.PlaneArray.CopyTo(pp, 0); hull.PlaneArray.CopyTo(pp, 6); var h = new Hull3d(pp); return(new Box3d(h.ComputeCorners())); }
public void ComputeCorners_Cube() { var hull = new Hull3d(new[] { new Plane3d(-V3d.XAxis, V3d.Zero), new Plane3d(-V3d.YAxis, V3d.Zero), new Plane3d(-V3d.ZAxis, V3d.Zero), new Plane3d(V3d.XAxis, V3d.One), new Plane3d(V3d.YAxis, V3d.One), new Plane3d(V3d.ZAxis, V3d.One) }); var corners = hull.ComputeCorners(); var expectedCorners = new [] { V3d.OOO, V3d.OOI, V3d.OIO, V3d.OII, V3d.IOO, V3d.IOI, V3d.IIO, V3d.III }; Assert.IsTrue(corners.SetEquals(expectedCorners)); }