public ICollection <Vector2D> ComputePositionsOnPlane(IEnumerable <Vector3D> positions) { if (positions == null) { throw new ArgumentNullException("positions"); } IList <Vector2D> positionsOnPlane = new List <Vector2D>(CollectionAlgorithms.EnumerableCount(positions)); foreach (Vector3D position in positions) { Vector3D intersectionPoint; if (IntersectionTests.TryRayPlane(Vector3D.Zero, position.Normalize(), _normal, _d, out intersectionPoint)) { Vector3D v = intersectionPoint - _origin; positionsOnPlane.Add(new Vector2D(_xAxis.Dot(v), _yAxis.Dot(v))); } else { // Ray does not intersect plane } } return(positionsOnPlane); }
public void RayPlaneIntersects() { Vector3D intersectionPoint; Vector3D normal = Vector3D.UnitX; Assert.IsTrue(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX, normal, planeD(Vector3D.UnitX, normal), out intersectionPoint)); }
public void RayPlaneOppositeDirection2() { Vector3D intersectionPoint; Vector3D normal = Vector3D.UnitX; Assert.IsFalse(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX, normal, planeD(-Vector3D.UnitX, normal), out intersectionPoint)); }
public void RayPlaneParallel() { Vector3D intersectionPoint; Vector3D normal = Vector3D.UnitY; Assert.IsFalse(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX, normal, planeD(Vector3D.UnitY, normal), out intersectionPoint)); }