예제 #1
0
        private MasterGeoObj[] checkSphereFlatface(AbstractSphere abstractSphere, flatfaceBehave flatfaceBehave)
        {
            intersectionFigData data = IntersectionMath.SpherePlaneIntersection(abstractSphere, flatfaceBehave);

            MasterGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.circle)
            {
                DependentPoint centerPoint     = GeoObjConstruction.dPoint(data.vectordata[0]);
                Vector3        radiusDirection = Vector3.up;
                if (Vector3.Cross(radiusDirection, data.vectordata[1]).magnitude == 0)
                {
                    radiusDirection = Vector3.right;
                }
                radiusDirection = Vector3.Cross(data.vectordata[1], radiusDirection).normalized;

                DependentPoint  edgePoint = GeoObjConstruction.dPoint(data.vectordata[0] + data.floatdata[0] * radiusDirection);
                DependentCircle newCircle = GeoObjConstruction.dCircle(centerPoint, edgePoint, data.vectordata[1]);
                mgoResult = new MasterGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(1), newCircle.setIntersectionFigure(2) };
            }
            else if (data.figtype == GeoObjType.point)
            {
                mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) };
            }
            return(mgoResult);
        }
예제 #2
0
        private MasterGeoObj[] checkSphereSphere(AbstractSphere abstractSphere1, AbstractSphere abstractSphere2)
        {
            intersectionFigData data = IntersectionMath.SphereSphereIntersection(abstractSphere1, abstractSphere2);

            Debug.Log("Data produces " + data.figtype.ToString());
            Debug.Log("Point Value " + data.vectordata[0].ToString());

            MasterGeoObj[] mgoResult = null;
            if (data.figtype == GeoObjType.circle)
            {
                DependentPoint centerPoint     = GeoObjConstruction.dPoint(data.vectordata[0]);
                Vector3        radiusDirection = Vector3.up;
                if (Vector3.Cross(radiusDirection, data.vectordata[1]).magnitude == 0)
                {
                    radiusDirection = Vector3.right;
                }
                radiusDirection = Vector3.Cross(data.vectordata[1], radiusDirection).normalized;

                DependentPoint  edgePoint = GeoObjConstruction.dPoint(data.vectordata[2]);
                DependentCircle newCircle = GeoObjConstruction.dCircle(centerPoint, edgePoint, data.vectordata[1]);
                mgoResult = new MasterGeoObj[] { centerPoint.setIntersectionFigure(0), edgePoint.setIntersectionFigure(0), newCircle.setIntersectionFigure(0) };
            }
            else if (data.figtype == GeoObjType.point)
            {
                mgoResult = new MasterGeoObj[] { GeoObjConstruction.dPoint(data.vectordata[0]) };
            }
            return(mgoResult);
        }
예제 #3
0
        private void updateCircleLine(MasterGeoObj mgo, MasterGeoObj masterGeoObj1, MasterGeoObj masterGeoObj2)
        {
            intersectionFigData data = IntersectionMath.CircleLineIntersection(masterGeoObj1.GetComponent <AbstractCircle>(), masterGeoObj2.GetComponent <straightEdgeBehave>());

            if (data.figtype == mgo.figType)
            {
                switch (data.figtype)
                {
                case GeoObjType.point:
                    mgo.Position3 = data.vectordata[0];
                    mgo.AddToRManager();
                    break;

                case GeoObjType.circle:
                    DependentCircle circle = mgo.GetComponent <DependentCircle>();
                    circle.centerPos        = data.vectordata[0];
                    circle.normalDir        = data.vectordata[1];
                    circle.center.Position3 = data.vectordata[0];
                    circle.edgePos          = data.vectordata[2];
                    circle.edge.Position3   = data.vectordata[2];
                    circle.AddToRManager();
                    circle.edge.AddToRManager();
                    circle.center.AddToRManager();
                    break;

                default:
                    break;
                }
            }
            else if (data.figtype == GeoObjType.none)
            {
                mgo.DeleteGeoObj();
            }
            else
            {
                Debug.LogWarning("TYPE MISMATCH");
            }
        }