示例#1
0
        public static bool Is2DPointOnBorder(Vector2 point, Vector2 quadCenter, float quadWidth, float quadHeight, Vector2 quadRight,
                                             Vector2 quadUp, QuadEpsilon epsilon = new QuadEpsilon())
        {
            SegmentEpsilon segmentEps = new SegmentEpsilon();

            segmentEps.PtOnSegmentEps = epsilon.WireEps;

            List <Vector2> corners = Calc2DQuadCornerPoints(quadCenter, new Vector2(quadWidth, quadHeight), quadRight, quadUp);

            for (int ptIndex = 0; ptIndex < corners.Count; ++ptIndex)
            {
                Vector2 startPt = corners[ptIndex];
                Vector2 endPt   = corners[(ptIndex + 1) % corners.Count];
                if (SegmentMath.Is2DPointOnSegment(point, startPt, endPt, segmentEps))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        public static bool Raycast(Ray ray, out float t, Vector3 startPoint, Vector3 endPoint, SegmentEpsilon epsilon = new SegmentEpsilon())
        {
            if (CylinderMath.Raycast(ray, out t, startPoint, endPoint, epsilon.RaycastEps))
            {
                return(true);
            }

            if (SphereMath.Raycast(ray, out t, startPoint, epsilon.RaycastEps))
            {
                return(true);
            }
            return(SphereMath.Raycast(ray, out t, endPoint, epsilon.RaycastEps));
        }
示例#3
0
        public static bool Is2DPointOnSegment(Vector2 point, Vector2 startPoint, Vector2 endPoint, SegmentEpsilon epsilon = new SegmentEpsilon())
        {
            float pointDistToSegment = point.GetDistanceToSegment(startPoint, endPoint);

            return(pointDistToSegment <= epsilon.PtOnSegmentEps);
        }