コード例 #1
0
        //---------------------------------------------------------------------------------------------
        //Трансформация траектоории (центрирование, поворот, растяжение)
        private Curve2D TransformateTrajectory(
            Curve2D trajectory,
            EllipseDescriptor approximateEllipse
            )
        {
            //Центрирование
            Curve2D transformedTrajectory = this.CentreTrajectory(trajectory, approximateEllipse);

            //Поворот параллельно координатной оси
            double rotationAngleToAxis = approximateEllipse.GetAngleBetweenOxAndPrincipalAxis();

            transformedTrajectory =
                this.RotateTrajectory(transformedTrajectory, rotationAngleToAxis);

            //Растяжение
            EllipseOrientaion     primaryOrientation    = approximateEllipse.GetOrientaion();
            TrajectoryOrientation trajectoryOrientation =
                this.DetectTrajectoryOrientation(primaryOrientation, rotationAngleToAxis);
            double koefficientOfStretch = 1 / approximateEllipse.GetCompressionRatio();

            transformedTrajectory = this.StretchingTrajectory
                                        (transformedTrajectory, trajectoryOrientation, koefficientOfStretch);

            //Поворот траектории до пересечения первой точки с осью OX
            Point2D firstPointTrajectory = transformedTrajectory[0];
            double  rotationAngle        = Mathem.Arctg(firstPointTrajectory.Y, firstPointTrajectory.X);

            transformedTrajectory =
                this.RotateTrajectory(transformedTrajectory, rotationAngle);
            return(transformedTrajectory);
        }
コード例 #2
0
        public void WhenPowerArgumentsIsValid_ShouldCorrectCount(int powerNumber, int powerDegree, int powerResult)
        {
            var mathem = new Mathem();

            var result = mathem.Power(powerNumber, powerDegree);

            Assert.AreEqual(powerResult, result);
        }
コード例 #3
0
        public void WhenFactorialArgumentsIsValid_ShouldCorrectCount(int factorialNumber, long factorialResult)
        {
            var mathem = new Mathem();

            var result = mathem.Factorial(factorialNumber);

            Assert.AreEqual(factorialResult, result);
        }
コード例 #4
0
        public void WhenAFactorialArgumentIsInvalid_ShouldShowException()
        {
            int test   = -14;
            var mathem = new Mathem();

            Assert.Throws <ArgumentException>(() => {
                var result = mathem.Factorial(test);
            });
        }
コード例 #5
0
        public void WhenMultiplicationArgumentsIsValid_ShouldCorrectCount(int multiplicationNumber1, int multiplicationNumber2,
                                                                          int multiplicationResult)
        {
            var mathem = new Mathem();

            var result = mathem.Multiplication(multiplicationNumber1, multiplicationNumber2);

            Assert.AreEqual(multiplicationResult, result);
        }
コード例 #6
0
        //-------------------------------------------------------------------------------------------
        //Вычисление фазовых сдвигов по траектории
        private double[] CalculatePhaseShifts(Curve2D trajectory)
        {
            int shiftsCount = trajectory.PointsCount;

            double[] phaseShifts = new double[shiftsCount];

            for (int index = 0; index < shiftsCount; index++)
            {
                Point2D point      = trajectory[index];
                double  phaseShift = Mathem.Arctg(point.Y, point.X);
                phaseShifts[index] = phaseShift;
            }
            return(phaseShifts);
        }
コード例 #7
0
    public void FindNextPosition()
    {
        pathFound = false;
        stopCour  = false;
        TargetFinderObject.GetComponent <SphereCollider>().enabled = true;
        agent.ResetPath();
        GameObject movingTo = new GameObject("Moving_" + this.gameObject.name);
        Vector3    pos      = transform.position;

        pos = new Vector3(pos.x + Random.Range(-maxXOffset, maxXOffset), pos.y, pos.z + Random.Range(-maxZOffset, maxZOffset));
        if (plane == null)
        {
            pos.y = Terrain.activeTerrain.SampleHeight(pos);
        }
        else
        {
            pos.y = Mathem.FindYOnPlane(pos.x, pos.z, plane);
        }
        movingTo.transform.position = pos;
        agent.destination           = movingTo.transform.position;
        testTarget = movingTo;
    }
コード例 #8
0
        //-----------------------------------------------------------------------------------------
        //Один действительный и два комплексно-сопряженных корня
        private Complex[] GetOneRealAndTwoComplexRoots(double q, double r, double qCube)
        {
            Complex complex1 = new Complex();
            Complex complex2 = new Complex();
            Complex complex3 = new Complex();

            double absR = Math.Abs(r);

            if (q > 0)
            {
                double t  = Mathem.Arch(absR / Math.Sqrt(qCube)) / 3;
                double x1 = -2 * Math.Sign(r) * Math.Sqrt(q) * Mathem.Ch(t) - a / 3;

                double realPart      = Math.Sign(r) * Math.Sqrt(q) * Mathem.Ch(t) - a / 3;
                double imaginaryPart = Math.Sqrt(3) * Math.Sqrt(q) * Mathem.Sh(t);

                complex1 = new Complex(x1, 0);
                complex2 = new Complex(realPart, imaginaryPart);
                complex3 = new Complex(realPart, -imaginaryPart);
            }
            else
            {
                double absQ = Math.Abs(q);
                double t    = Mathem.Arsh(absR / Math.Sqrt(absQ * absQ * absQ)) / 3;
                double x1   = -2 * Math.Sign(r) * Math.Sqrt(absQ) * Mathem.Sh(t) - a / 3;

                double realPart      = Math.Sign(r) * Math.Sqrt(absQ) * Mathem.Sh(t) - a / 3;
                double imaginaryPart = Math.Sqrt(3) * Math.Sqrt(absQ) * Mathem.Ch(t);

                complex1 = new Complex(x1, 0);
                complex2 = new Complex(realPart, imaginaryPart);
                complex3 = new Complex(realPart, -imaginaryPart);
            }

            Complex[] roots = new Complex[] { complex1, complex2, complex3 };
            return(roots);
        }
        //---------------------------------------------------------------------------------------------
        //Вычисление фазы в точке
        private double CalculatePhase(double x, double y)
        {
            double phase = Mathem.Arctg(y, x);

            return(phase);
        }