Exemplo n.º 1
0
        public static bool IsPlaneInsectCircle(Vector3 normal, float d, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointArrayInfo insect)
        {
            float tmp = Mathf.Abs(Vector3.Dot(plane.mNormal.normalized, normal.normalized));

            if (1 - tmp < 1e-5f)
            {
                return(false); // 平行 或 共面
            }
            GeoInsectPointArrayInfo tmp1 = new GeoInsectPointArrayInfo();
            bool inSect = IsPlaneInsectPlane(normal, d, plane.mNormal, plane.mD, ref tmp1);

            if (inSect)
            {
                Vector3 line1 = tmp1.mHitGlobalPoint.mPointArray[0] + tmp1.mHitGlobalPoint.mPointArray[1];
                GeoLineUtils.IsLineInsectCirclePlane2(tmp1.mHitGlobalPoint.mPointArray[0], line1, center, r, plane, ref insect);
            }
            return(insect.mIsIntersect);
        }
Exemplo n.º 2
0
        public static bool IsCircleInsectCircle3(Vector3 center1, float r1, GeoPlane plane1, Vector3 center2, float r2, GeoPlane plane2, ref GeoInsectPointArrayInfo insect)
        {
            float dot = Mathf.Abs(Vector3.Dot(plane1.mNormal, plane2.mNormal));

            if (1 - dot < GeoUtils.PRECISION)
            {
                if (GeoPlaneUtils.IsPointOnPlane(plane2.mNormal, plane2.mD, center1)) // 共面
                {
                    return(IsCircleInsectCirclePlane2(center1, r1, center2, r2, plane2, ref insect));
                }
                return(false);
            }
            GeoInsectPointArrayInfo tmp = new GeoInsectPointArrayInfo();
            bool isInsect = GeoPlaneUtils.IsPlaneInsectCircle(plane1.mNormal, plane1.mD, center2, r2, plane2, ref tmp);

            if (isInsect)
            {
                Vector3 lin1 = tmp.mHitGlobalPoint.mPointArray[0];
                Vector3 lin2 = lin1 + tmp.mHitGlobalPoint.mPointArray[1];
                GeoLineUtils.IsLineInsectCirclePlane2(lin1, lin2, center1, r1, plane1, ref insect);
            }
            return(insect.mIsIntersect);
        }