Exemplo n.º 1
0
        internal static InteractablePrism iPrism(AbstractPolygon polygon)
        {
            List <AbstractLineSegment> lineList0  = polygon.transform.GetComponent <AbstractPolygon>().lineList;
            List <AbstractPoint>       pointList0 = polygon.transform.GetComponent <AbstractPolygon>().pointList;

            //make new lists for the points and lines in the new plane
            List <AbstractLineSegment> lineList1  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList1 = new List <AbstractPoint>();

            //create new points for the new plane.
            foreach (AbstractPoint point in pointList0)
            {
                AbstractPoint newPoint = iPoint(point.Position3);
                pointList1.Add(newPoint);
            }

            //create new lines for the new plane.
            foreach (AbstractLineSegment line in lineList0)
            {
                if (line.GetComponent <InteractableLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index], pointList1[point2Index]);
                    lineList1.Add(newLine);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
                else if (line.GetComponent <DependentLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index], pointList1[point2Index]);
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
            }

            AbstractPolygon plane1 = iPolygon(lineList1, pointList1);


            plane1.InitializeFigure();
            List <AbstractPolygon> sideList = new List <AbstractPolygon>();

            foreach (AbstractLineSegment l in lineList0)
            {
                int lineIndex = lineList0.IndexOf(l);

                sideList.Add(makePlaneWall(lineIndex, lineList0, lineList1));
            }

            InteractablePrism      prism    = InteractablePrism.Constructor();
            List <AbstractPolygon> baseList = new List <AbstractPolygon>();

            baseList.Add(polygon);
            baseList.Add(plane1);

            prism.bases = baseList;
            prism.sides = sideList;

            prism.vertexPoints.ForEach(p => HW_GeoSolver.ins.AddDependence(prism, p));
            prism.lineSegments.ForEach(l => HW_GeoSolver.ins.AddDependence(prism, l));
            prism.bases.ForEach(b => HW_GeoSolver.ins.AddDependence(prism, b));
            prism.sides.ForEach(b => HW_GeoSolver.ins.AddDependence(prism, b));
            prism.InitializeFigure();

            return(prism);
        }
Exemplo n.º 2
0
        internal static InteractablePrism dPrism(AbstractPolygon polygon, Vector3 base2Pos)
        {
            List <AbstractLineSegment> lineList0  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList0 = new List <AbstractPoint>();

            lineList0  = polygon.transform.GetComponent <AbstractPolygon>().lineList;
            pointList0 = polygon.transform.GetComponent <AbstractPolygon>().pointList;

            //make new lists for the points and lines in the new plane
            List <AbstractLineSegment> lineList1  = new List <AbstractLineSegment>();
            List <AbstractPoint>       pointList1 = new List <AbstractPoint>();

            //create new points for the new plane.
            foreach (AbstractPoint point in pointList0)
            {
                AbstractPoint newPoint = dPoint(point.Position3 - polygon.Position3 + base2Pos);
                pointList1.Add(newPoint);
            }

            //create new lines for the new plane.
            foreach (AbstractLineSegment line in lineList0)
            {
                if (line.GetComponent <InteractableLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <InteractableLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index].GetComponent <AbstractPoint>(), pointList1[point2Index].GetComponent <AbstractPoint>());
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
                else if (line.GetComponent <DependentLineSegment>() != null)
                {
                    int point1Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point1);
                    int point2Index = pointList0.IndexOf(line.transform.GetComponent <DependentLineSegment>().point2);

                    AbstractLineSegment newLine = iLineSegment(pointList1[point1Index].GetComponent <AbstractPoint>(), pointList1[point2Index].GetComponent <AbstractPoint>());
                    lineList1.Add(newLine);

                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point1Index]);
                    HW_GeoSolver.ins.AddDependence(newLine, pointList1[point2Index]);
                }
            }

            AbstractPolygon plane1 = dPolygon(lineList1, pointList1);

            plane1.AddToRManager();

            foreach (AbstractLineSegment line in lineList1)
            {
                HW_GeoSolver.ins.AddDependence(plane1, line);
            }

            plane1.transform.GetComponent <AbstractPolygon>().InitializeFigure();
            List <AbstractPolygon> sideList = new List <AbstractPolygon>();

            foreach (AbstractLineSegment line0 in lineList0)
            {
                int lineIndex = lineList0.IndexOf(line0);


                AbstractLineSegment lineTest = lineList0[lineIndex];

                sideList.Add(makePlaneWall(lineIndex, lineList0, lineList1));
            }

            InteractablePrism      prism    = InteractablePrism.Constructor();
            List <AbstractPolygon> baseList = new List <AbstractPolygon>
            {
                polygon,
                plane1
            };

            prism.bases = baseList;
            prism.sides = sideList;

            foreach (AbstractPolygon poly in baseList)
            {
                HW_GeoSolver.ins.AddDependence(prism, poly);
            }
            foreach (AbstractPolygon poly in sideList)
            {
                HW_GeoSolver.ins.AddDependence(prism, poly);
            }

            prism.vertexPoints.ForEach(p => HW_GeoSolver.ins.AddDependence(prism, p));

            prism.InitializeFigure();

            return(prism);
        }