Ejemplo n.º 1
0
        public void TestMethod2()
        {
            Figure figure = new Figure();

            figure.Add(new Point2(0, 0));
            figure.Add(new Point2(2000, 0));
            figure.Add(new Point2(2000, 2000));
            figure.Add(new Point2(0, 2000));
            RDMengine engine = new RDMengine(figure, 1, 1);
            Screw     screw  = new Screw(new float[] { 0, (float)(-5.0 * Math.Pow(10, -6)), 0, 0, 0, 0 }, new Point2(0, 1000).toVector());

            /*Assert.AreEqual(
             *   engine.getDeformationFunctionY(2000, 1000, 0, (float)(-5.0 * Math.Pow(10, -8)), true, 2).calcY(1000),
             *   engine.getDeformationFunctionY(2000, 1000, 0, (float)(-5.0 * Math.Pow(10, -8)), false, 2).calcY(1000)
             *   );*/
            Figure results1 = engine.calculateDeformation(figure[0], figure[1], screw, null, true);

            show(results1);
            screw = screw.changeApplicationPoint(figure[1].toVector());
            Figure results2 = engine.calculateDeformation(figure[0], figure[1], null, screw, true);
        }
Ejemplo n.º 2
0
        public void applyScrew(Screw screw)
        {
            Point3[] ptsAround = this.figure.getPtsAround(screw.aplicationPoint.toPoint3());
            if (ptsAround == null)
            {
                throw new NotInFigureExeption();
            }
            FloatVector   directorPtAround = ptsAround[1].toVector().substract(ptsAround[0].toVector()).normalize();
            FloatVector   ptOnFigure       = ptsAround[0].toVector().add(directorPtAround.multiplyByScalar(screw.aplicationPoint.scalarProduct(directorPtAround)));
            Screw         screwOnFigure    = Screw.fromWrenchAndTwist(screw.getWrench(), screw.getTwist(), ptOnFigure);
            List <Figure> listMoves        = new List <Figure>();

            listMoves.Add(this.calculateDeformation(ptsAround[0], ptsAround[1], screwOnFigure, null, true));
            Point3 ptmax = this.getFarestPoint(screwOnFigure);
            int    i     = 0;

            int[]           posPtsAround = new int[] { Array.IndexOf(this.figure.ToArray(), ptsAround[0]), Array.IndexOf(this.figure.ToArray(), ptsAround[1]) };
            int             increment = posPtsAround[0] < posPtsAround[1] ? 1 : -1;
            bool            endLeft = false, endRight = false;
            int             nbBoucles     = 1;
            List <Point3[]> ptsUsedToCalc = new List <Point3[]>();

            ptsUsedToCalc.Add(ptsAround);
            while (!endLeft || !endRight)
            {
                Point3 ptStart, ptEnd;
                foreach (bool right in new bool[] { true, false })
                {
                    int indRef = right ? 1 : 0;
                    ptStart = this.getPt(true, right, posPtsAround[indRef], nbBoucles, increment, this.figure);
                    ptEnd   = this.getPt(false, right, posPtsAround[indRef], nbBoucles, increment, this.figure);
                    ptsUsedToCalc.Add(new Point3[] { ptStart, ptEnd });
                    listMoves.Add((right ? endRight : endLeft) ? null : this.calculateDeformation(ptStart, ptEnd, null, screwOnFigure.changeApplicationPoint(ptStart.toVector()), false));
                    if (ptEnd == ptmax)
                    {
                        if (right)
                        {
                            endRight = true;
                        }
                        else
                        {
                            endLeft = true;
                        }
                    }
                }
                ;
                i += 2;
                nbBoucles++;
            }
            this.figure = this.getNewFigure(this.figure, listMoves, ptsUsedToCalc, ptmax);
        }