Ejemplo n.º 1
0
        public double DistanceSquared(Vector2d p)
        {
            double t = (p - Center).Dot(Direction);

            if (t >= Extent)
            {
                return(P1.DistanceSquared(p));
            }
            else if (t <= -Extent)
            {
                return(P0.DistanceSquared(p));
            }
            Vector2d proj = Center + t * Direction;

            return(proj.DistanceSquared(p));
        }
Ejemplo n.º 2
0
        public float DistanceSquared(Vector2f p)
        {
            float t = (p - Center).Dot(Direction);

            if (t >= Extent)
            {
                return(P1.DistanceSquared(p));
            }
            else if (t <= -Extent)
            {
                return(P0.DistanceSquared(p));
            }
            Vector2f proj = Center + t * Direction;

            return((proj - p).LengthSquared);
        }
Ejemplo n.º 3
0
        public double DistanceSquared(Vector3d p, out double t)
        {
            t = (p - Center).Dot(Direction);
            if (t >= Extent)
            {
                t = Extent;
                return(P1.DistanceSquared(p));
            }
            else if (t <= -Extent)
            {
                t = -Extent;
                return(P0.DistanceSquared(p));
            }
            Vector3d proj = Center + t * Direction;

            return((proj - p).LengthSquared);
        }