コード例 #1
0
        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);
        }
コード例 #2
0
        public void RayPlaneIntersects()
        {
            Vector3D intersectionPoint;
            Vector3D normal = Vector3D.UnitX;

            Assert.IsTrue(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX,
                                                        normal, planeD(Vector3D.UnitX, normal), out intersectionPoint));
        }
コード例 #3
0
        public void RayPlaneOppositeDirection2()
        {
            Vector3D intersectionPoint;
            Vector3D normal = Vector3D.UnitX;

            Assert.IsFalse(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX,
                                                         normal, planeD(-Vector3D.UnitX, normal), out intersectionPoint));
        }
コード例 #4
0
        public void RayPlaneParallel()
        {
            Vector3D intersectionPoint;
            Vector3D normal = Vector3D.UnitY;

            Assert.IsFalse(IntersectionTests.TryRayPlane(Vector3D.Zero, Vector3D.UnitX,
                                                         normal, planeD(Vector3D.UnitY, normal), out intersectionPoint));
        }