Пример #1
0
        private void SaveParameters()
        {
            switch (Settings.Scaffold)
            {
            case IdealCurveScaffold.Polynomial:
                Settings.Parameters.Polynomial.A = UiControls.TryGetValue <double>(uiCntPol_a_Num);
                Settings.Parameters.Polynomial.B = UiControls.TryGetValue <double>(uiCntPol_b_Num);
                Settings.Parameters.Polynomial.C = UiControls.TryGetValue <double>(uiCntPol_c_Num);
                Settings.Parameters.Polynomial.D = UiControls.TryGetValue <double>(uiCntPol_d_Num);
                Settings.Parameters.Polynomial.E = UiControls.TryGetValue <double>(uiCntPol_e_Num);
                Settings.Parameters.Polynomial.F = UiControls.TryGetValue <double>(uiCntPol_f_Num);
                Settings.Parameters.Polynomial.I = UiControls.TryGetValue <double>(uiCntPol_i_Num);
                break;

            case IdealCurveScaffold.Hyperbolic:
                double userValue = UiControls.TryGetValue <double>(uiCntHyp_f_Num);
                Settings.Parameters.Hyperbolic.F = Mathematics.IsZero(userValue) ? 0.0001 : userValue;
                Settings.Parameters.Hyperbolic.A = UiControls.TryGetValue <double>(uiCntHyp_a_Num);
                Settings.Parameters.Hyperbolic.B = UiControls.TryGetValue <double>(uiCntHyp_b_Num);
                Settings.Parameters.Hyperbolic.C = UiControls.TryGetValue <double>(uiCntHyp_c_Num);
                Settings.Parameters.Hyperbolic.D = UiControls.TryGetValue <double>(uiCntHyp_d_Num);
                Settings.Parameters.Hyperbolic.I = UiControls.TryGetValue <double>(uiCntHyp_i_Num);
                break;

            case IdealCurveScaffold.WaveformSine:
            case IdealCurveScaffold.WaveformSquare:
            case IdealCurveScaffold.WaveformTriangle:
            case IdealCurveScaffold.WaveformSawtooth:
                Settings.Parameters.Waveform.M = UiControls.TryGetValue <double>(uiCntWave_m_Num);
                Settings.Parameters.Waveform.N = UiControls.TryGetValue <double>(uiCntWave_n_Num);
                Settings.Parameters.Waveform.O = UiControls.TryGetValue <double>(uiCntWave_o_Num);
                Settings.Parameters.Waveform.K = UiControls.TryGetValue <double>(uiCntWave_k_Num);
                break;
            }
        }
Пример #2
0
        private void CalculateStandardDeviations()
        {
            int            meanTypes = new MeanTypesStrings().Count();
            double         stdDeviation;
            IList <double> averagesValues;
            IList <double> idealValues;

            for (int i = 0; i < Data.Count; i++)
            {
                for (int j = 0; j < Noises.Count; j++)
                {
                    Data[i][j].GenerateIdealCurve(Settings.Pcd.Scaffold, Settings.Pcd.Parameters, Settings.Ui.StartX, Settings.Ui.EndX, Settings.Ui.PointsNo);
                    Data[i][j].PropagateIdealCurve(Settings.Ui.CurvesNo);
                    Data[i][j].MakeNoiseOfGaussian(Settings.Ui.CurvesNo, Noises[j]);
                    MakeMalformation((Phenomenon)i, Data[i][j], Settings.Ui.CurvesNo / 2);

                    for (int k = 0; k < meanTypes; k++)
                    {
                        Data[i][j].TryMakeAverageCurve((MeanType)k, Settings.Ui.CurvesNo);
                        SeriesAssist.CopyPoints(Data[i][j].AverageCurve, Averages[i][j][k]);
                        averagesValues         = SeriesAssist.GetValues(Averages[i][j][k]);
                        idealValues            = SeriesAssist.GetValues(Data[i][j].IdealCurve);
                        stdDeviation           = Mathematics.GetRelativeStandardDeviation(averagesValues, idealValues);
                        StdDeviations[i][j][k] = stdDeviation;
                    }
                }
            }
        }
Пример #3
0
        private GameActions TurnToAim(Player bot, Position aim)
        {
            var wantedAngle = Mathematics.CalcAngle(bot.Centre, aim);
            var isBigRotate = Math.Abs(bot.Direction - wantedAngle) > bigRotate;

            if (bot.Direction <= 180)
            {
                if (wantedAngle >= bot.Direction &&
                    wantedAngle <= bot.Direction + 180)
                {
                    return(isBigRotate ? GameActions.FastRight : GameActions.Right);
                }
                else
                {
                    return(isBigRotate ? GameActions.FastLeft : GameActions.Left);
                }
            }
            else
            {
                if (wantedAngle >= bot.Direction - 180 &&
                    wantedAngle <= bot.Direction)
                {
                    return(isBigRotate ? GameActions.FastLeft : GameActions.Left);
                }
                else
                {
                    return(isBigRotate ? GameActions.FastRight : GameActions.Right);
                }
            }
        }
Пример #4
0
        private void CalculateSpeed()
        {
            long sentBytes    = 0;
            long recivedBytes = 0;

            foreach (var networkInterface in _networkAdoptor)
            {
                var interfaceStats = networkInterface.GetIPv4Statistics();
                sentBytes    += interfaceStats.BytesSent;
                recivedBytes += interfaceStats.BytesReceived;
            }

            long sentSpeed    = sentBytes - _totalSentbytes;
            long recivedSpeed = recivedBytes - _totalReceivedbytes;

            if (_totalSentbytes == 0 && _totalReceivedbytes == 0)
            {
                sentSpeed    = 0;
                recivedSpeed = 0;
            }

            lblDownload.Content = Helper.UsageStringHelper(recivedSpeed, NetworkSettings.UnitTypes.KBytepers);
            lblUpload.Content   = Helper.UsageStringHelper(sentSpeed, NetworkSettings.UnitTypes.KBytepers);

            _networkUsage.Add(new NetworkUsageData(DateTime.Now, sentSpeed, recivedSpeed));
            lblMaxVolumeSpeed.Content =
                Helper.UsageStringHelper(Mathematics.GetUpperRounded(_networkUsage.GetMaximumAtAll()),
                                         NetworkSettings.UnitTypes.KBytepers);

            _totalSentbytes     = sentBytes;
            _totalReceivedbytes = recivedBytes;
        }
Пример #5
0
        private static void Split(Tensor x, int axis, IList <Tensor> ys, bool useGradients)
        {
            int xstride = axis == 0 ? x.Length : x.Strides[axis - 1];
            int ydim    = axis == 0 ? 1 : x.Length / xstride;

            float[] xw = useGradients ? x.Gradient : x.Weights;

            for (int i = 0, offx = 0, ii = ys.Count; i < ii; i++)
            {
                Tensor  y       = ys[i];
                float[] yw      = useGradients ? y.Gradient : y.Weights;
                int     ystride = axis == 0 ? y.Length : y.Strides[axis - 1];

                for (int n = 0, offxx = offx, offy = 0; n < ydim; n++, offxx += xstride, offy += ystride)
                {
                    if (useGradients)
                    {
                        Mathematics.Add(ystride, xw, offxx, yw, offy);
                    }
                    else
                    {
                        Vectors.Copy(ystride, xw, offxx, yw, offy);
                    }
                }

                offx += ystride;
            }
        }
Пример #6
0
        public static void Solve()
        {
            var        T   = Scanner.Scan <int>();
            const long inf = long.MaxValue;

            while (T-- > 0)
            {
                var(X, Y, P, Q) = Scanner.Scan <long, long, long, long>();
                var a      = X * 2 + Y * 2;
                var b      = P + Q;
                var answer = inf;
                for (var t1 = X; t1 < X + Y; t1++)
                {
                    for (var t2 = P; t2 < P + Q; t2++)
                    {
                        var(t, lcm) = Mathematics.ChineseRemainderTheorem(new[] { t1, t2 }, new[] { a, b });
                        if (lcm == 0)
                        {
                            continue;
                        }
                        answer = Math.Min(answer, t);
                    }
                }

                Console.WriteLine(answer == inf ? "infinity" : $"{answer}");
            }
        }
Пример #7
0
        private static double?GeneralizedOfStraight(IList <double> set, int rank)
        {
            IList <double> powers = Lists.GetCopy(set);

            Lists.Exponentiate(powers, rank);
            return(Mathematics.Root(Lists.Sum(powers) / set.Count, rank));
        }
Пример #8
0
        /// <summary>
        /// Zwraca startowy indeks kawalka planszy od ktorego
        /// zaczne sprawdzac kolizje.
        /// </summary>
        /// <param name="position"></param>
        /// <returns>Indeks startowego pola</returns>
        /// <author>Michal Ziober</author>
        private int GetStartIndex(float position)
        {
            int index = Mathematics.PositionToIndex(position);
            int min   = System.Math.Max(0, index) + 1;

            return(min);
        }
Пример #9
0
 // Creates a random set of genes for this entity
 public void RandomizeGenes()
 {
     foreach (string geneType in this.geneTypes)
     {
         this.genes.Add(geneType, Mathematics.GetCauchyDistributedRandomNumber());
     }
 }
Пример #10
0
        private bool checkLinesOnLine(List <MyPoint> points, LineType linesposition)
        {
            MyPoint startpoint = points.ElementAt(0);
            MyPoint endpoint   = points.ElementAt(points.Count - 1);

            foreach (MyPoint point in points)
            {
                if (linesposition == LineType.ParallelOY)
                {
                    if (point.X != startpoint.X)
                    {
                        return(false);
                    }
                }
                else if (linesposition == LineType.ParallelOX)
                {
                    if (point.Y != startpoint.Y)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (Math.Abs((point.X - Mathematics.floor((((((point.Y - startpoint.Y) * (endpoint.X - startpoint.X)) /
                                                                 (endpoint.Y - startpoint.Y))) + startpoint.X), Mathematics.accuracy_medium))) > 0.9)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #11
0
        private int getFEnumber(List <MyNode> nodes, MyPoint CenterPoint, FESearchSpace space, int currentModel)
        {
            int    numberFE = 0;
            double radius   = Mathematics.FindDist(new MyPoint(nodes[0].X, nodes[0].Y, MyPoint.PointType.IsAreaNode), CenterPoint);

            foreach (MyNode thisnode in nodes)
            {
                MyFiniteElement thisFE = this.parent.currentFullModel.FiniteElementModels[currentModel].FiniteElements.Find(
                    FE => (FE.Nodes[0].X == thisnode.X && FE.Nodes[0].Y == thisnode.Y) ||
                    (FE.Nodes[1].X == thisnode.X && FE.Nodes[1].Y == thisnode.Y) ||
                    (FE.Nodes[2].X == thisnode.X && FE.Nodes[2].Y == thisnode.Y));
                foreach (MyNode FEnode in thisFE.Nodes)
                {
                    if (space == FESearchSpace.outside)
                    {
                        if (Mathematics.FindDist(new MyPoint(FEnode.X, FEnode.Y, MyPoint.PointType.IsAreaNode), CenterPoint) > radius)
                        {
                            numberFE++;
                        }
                    }
                    else if (space == FESearchSpace.inside)
                    {
                        if (Mathematics.FindDist(new MyPoint(FEnode.X, FEnode.Y, MyPoint.PointType.IsAreaNode), CenterPoint) < radius)
                        {
                            numberFE++;
                        }
                    }
                }
            }
            return(numberFE);
        }
Пример #12
0
        public bool IsIntersectingWith(PositionedCylinder _positionedCylinder, out Exception _exception)
        {
            _exception = null;


            Polygon _polygonToCheckFront = _positionedCylinder.GetCylinderFrontView();
            Polygon _polygonToCheckSide  = _positionedCylinder.GetCylinderSideView();
            Polygon _polygonThisFront    = this.GetCylinderFrontView();
            Polygon _polygonThisSide     = this.GetCylinderSideView();

            if ((_polygonToCheckFront.IntersectsWith(_polygonThisFront)) &&
                (_polygonToCheckSide.IntersectsWith(_polygonThisSide)))
            {
                _exception = new ValidationException("Two or more cylinders intersect physically.");
                return(true);
            }

            if (_positionedCylinder.Offset_mm < this.Offset_mm + _positionedCylinder.CrankThrow.CrankPinWidth_mm)
            {
                double _double1 = Mathematics.GetAbsoluteAngle_deg(_positionedCylinder.GetAbsoluteCrankThrowRotation_deg(0), true);
                double _double2 = Mathematics.GetAbsoluteAngle_deg(this.GetAbsoluteCrankThrowRotation_deg(0), true);

                //če imata ročici isti kot, potem gre za t.a. "articulated" connecting rod
                if (_double1 != _double2)
                {
                    _exception = new ValidationException("Two or more connecting rods intersect physically.");
                    return(true);
                }
            }


            return(false);
        }
Пример #13
0
 public void ChineseRemainderTheoremInvalidArgumentsTest()
 {
     Assert.Throws <ArgumentException>(() =>
                                       Mathematics.ChineseRemainderTheorem(new long[] { 1, 2 }, new long[] { 3 }));
     Assert.Throws <ArgumentException>(() =>
                                       Mathematics.ChineseRemainderTheorem(new long[] { 1, 2 }, new long[] { -1, -2 }));
 }
Пример #14
0
        public void SafeModuloTest()
        {
            var list = new List <long>();

            for (var i = 0; i <= 10; i++)
            {
                list.Add(i);
                list.Add(-i);
                list.Add(long.MinValue + i);
                list.Add(long.MinValue - i);
            }

            foreach (var a in list)
            {
                foreach (var b in list)
                {
                    if (b <= 0)
                    {
                        continue;
                    }
                    var value = ((ulong)(a % b) + (ulong)b) % (ulong)b;
                    Assert.That(value, Is.EqualTo(Mathematics.SafeModulo(a, b)));
                }
            }
        }
Пример #15
0
        private static bool SquareIntersect(BoundingBox boxA, BoundingBox boxB)
        {
            Mathematics maths = new Mathematics();
            //Get Center points.
            Point p1 = maths.GetRectangleCenterPoint(new Point(boxA.Dimension.Left, boxA.Dimension.Top), boxA.Dimension.Width, boxA.Dimension.Height);
            Point p2 = maths.GetRectangleCenterPoint(new Point(boxB.Dimension.Left, boxB.Dimension.Top), boxB.Dimension.Width, boxB.Dimension.Height);

            //Get distance between points
            double d = maths.DistanceBetweenPoints(p1, p2);

            //Get adjacent of right-angle-traingle formed by points p1 and p2.
            double x = maths.GetLateralDistanceBetweenPoints(p1, p2);

            //Get angle of intersection  between adjacent and hypotenuse of p1p2 triangle.
            double angle = maths.GetAngleAH(x, d);

            double d1;
            double d2;

            if (angle < 45)
            {
                d1 = maths.LengthOfHypotenuseFromAngleAndAdjacent(angle, boxA.Dimension.Width / 2);
                d2 = maths.LengthOfHypotenuseFromAngleAndAdjacent(angle, boxB.Dimension.Width / 2);
            }
            else
            {
                d1 = maths.LengthOfHypotenuseFromAngleAndAdjacent(90 - angle, boxA.Dimension.Height / 2);
                d2 = maths.LengthOfHypotenuseFromAngleAndAdjacent(90 - angle, boxB.Dimension.Height / 2);
            }

            return((d1 + d2) > d ? true : false);
        }
Пример #16
0
    public float EStretch(int order, bool suppress = false)
    {
        float e = 0f;

        //Not connected
        if (bondOrder == 0.0)
        {
            e = 0f;
        }

        Stretch param = GetStretchParameter();

        if (param == null)
        {
            if (!suppress)
            {
                throw new NoParameterException(typeof(Stretch), atom0, atom1);
            }
            e = 0f;
        }
        else
        {
            e = Mathematics.EStretch(distance, param.keq, param.req, order);
        }

        return(e);
    }
Пример #17
0
        public void ChineseRemainderTheorem2ItemsTest()
        {
            for (var a = 1; a <= 20; a++)
            {
                for (var b = 1; b <= 20; b++)
                {
                    for (var c = -10; c <= 10; c++)
                    {
                        for (var d = -10; d <= 10; d++)
                        {
                            var(rem, mod) = Mathematics.ChineseRemainderTheorem(new long[] { c, d }, new long[] { a, b });
                            var lcm = a * b / GreatestCommonDivisor(a, b);
                            if (mod == 0)
                            {
                                for (var x = 0; x < lcm; x++)
                                {
                                    Assert.That(x % a != c || x % b != d, Is.True);
                                }
                                continue;
                            }

                            Assert.That(mod, Is.EqualTo(lcm));
                            Assert.That(rem % a, Is.EqualTo(Mathematics.SafeModulo(c, a)));
                            Assert.That(rem % b, Is.EqualTo(Mathematics.SafeModulo(d, b)));
                        }
                    }
                }
            }
        }
Пример #18
0
        private static void Stack(IList <Tensor> xs, int axis, Tensor y, bool useGradients)
        {
            int xdim    = xs.Count;
            int ylen    = y.Length;
            int ystride = y.Strides[axis];

            float[] yw = useGradients ? y.Gradient : y.Weights;

            for (int offx = 0, offy = 0; offy < ylen; offx += ystride)
            {
                for (int i = 0; i < xdim; i++, offy += ystride)
                {
                    Tensor  x  = xs[i];
                    float[] xw = useGradients ? x.Gradient : x.Weights;

                    if (useGradients)
                    {
                        Mathematics.Add(ystride, xw, offx, yw, offy);
                    }
                    else
                    {
                        Vectors.Copy(ystride, xw, offx, yw, offy);
                    }
                }
            }
        }
Пример #19
0
        public void Update(GameTime gameTime)
        {
            SteeringForce    = new Vector2(0, 0);
            vectorDifference = Mathematics.Subtract(TargetAgent.Position, Agent.Position);
            distance         = Mathematics.Length(vectorDifference);

            Vector2 predictedPosition = Mathematics.Multiply(TargetAgent.Velocity, distance * predictionFactor);
            Vector2 targetPosition    = Mathematics.Add(TargetAgent.Position, predictedPosition);

            vectorDifference = Mathematics.Subtract(targetPosition, Agent.Position);
            distance         = Mathematics.Length(vectorDifference);

            if (distance < 2)
            {
                return;
            }

            rampSpeed = Agent.MaxSpeed * (distance / rampDistance);
            rampSpeed = Math.Min(rampSpeed, Agent.MaxSpeed);

            vectorDifference = Mathematics.Multiply(vectorDifference, rampSpeed / distance);

            force         = Mathematics.Subtract(vectorDifference, Agent.Velocity);
            SteeringForce = force;
        }
Пример #20
0
        private static void Unstack(Tensor x, int axis, IList <Tensor> ys, bool useGradients)
        {
            int xlen     = x.Length;
            int xdim     = x.Axes[axis];
            int xstride0 = x.Strides[axis];                         // axis inner stride
            int xstride1 = axis == 0 ? xlen : x.Strides[axis - 1];  // axis outer stride

            float[] xw = useGradients ? x.Gradient : x.Weights;

            for (int i = 0, offx = 0; i < xdim; i++, offx += xstride0)
            {
                Tensor  y  = ys[i];
                float[] yw = useGradients ? y.Gradient : y.Weights;

                for (int offxx = offx, offy = 0; offxx < xlen; offxx += xstride1, offy += xstride0)
                {
                    if (useGradients)
                    {
                        Mathematics.Add(xstride0, xw, offxx, yw, offy);
                    }
                    else
                    {
                        Vectors.Copy(xstride0, xw, offxx, yw, offy);
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Dodaje liny hamuj¹ce do lotniskowca
        /// </summary>
        protected void InitArrestingWires()
        {
            // arresting wires
            Carrier lCarrier = new Carrier(tileViews);

            float carrierBegin = lCarrier.GetBeginPosition().X;
            float carrierWidth = lCarrier.GetEndPosition().X - carrierBegin;

            float carrierCenter = carrierBegin + carrierWidth / 2.0f;

            int i;

            for (i = 0; i < lCarrier.CarrierTiles.Count; i++)
            {
                if (lCarrier.CarrierTiles[i] is EndAircraftCarrierTile)
                {
                    float xPos = Mathematics.IndexToPosition(lCarrier.CarrierTiles[i].TileIndex);
                    //LevelTile.Width
                    //+ 1.0f / 2.0f
                    float viewZ = -((float)(xPos - carrierCenter) + 47.2f);  //- 6.0f); // korekta

                    InitArrestingWire(viewZ);
                }
            }
            activeArrestingWires = new List <SceneNode>(arrestingWires.Count);
            arrestingWiresH      = new float[arrestingWires.Count];
        }
Пример #22
0
    IEnumerator MoveRoutine(Vector3 destination, float timeToMove)
    {
        _isMoving = true;

        Vector3 startPosition = transform.position;
        float   elapsedTime   = 0f;

        bool reachedDestination = false;

        while (!reachedDestination)
        {
            if (Vector3.Distance(transform.position, destination) < 0.01f)
            {
                reachedDestination = true;
                _board.PlaceGamePiece(this, (int)destination.x, (int)destination.y);
                break;
            }

            elapsedTime += Time.deltaTime;

            float t = Mathf.Clamp(elapsedTime / timeToMove, 0f, 1f);

            t = Mathematics.Interpolate(t, _interpolation);
            transform.position = Vector3.Lerp(startPosition, destination, t);

            yield return(null);
        }

        _isMoving = false;
    }
Пример #23
0
        public void Update(float dt)
        {
            SteeringForce = new Point(0, 0);
            foreach (var behavior in behaviorList)
            {
                behavior.Update();
                SteeringForce = Mathematics.Add(SteeringForce, behavior.SteeringForce);
            }

            SteeringForce = Mathematics.Truncate(SteeringForce, MaxForce);

            if (Mathematics.Length(SteeringForce) > _steeringForceThreshold)
            {
                Point acceleration = Mathematics.Multiply(SteeringForce, 1f / Mass);

                Velocity = Mathematics.Add(Velocity, acceleration);

                Position = Mathematics.Add(Position, Velocity);

                float speed = Mathematics.Length(Velocity);
                if (speed > _speedThreshold)
                {
                    Point velocity = Mathematics.Normalize(Velocity);
                    velocity = Mathematics.Lerp(Front, velocity, VelocityAlignmentFactor);
                    Front    = Mathematics.Normalize(velocity);
                }
            }
            else
            {
                Velocity = new Point(0, 0);
            }
        }
Пример #24
0
 public void Mathematics_Factorial_AllFactorialsShouldBeCorrect()
 {
     for (var i = 0; i < 12; i++)
     {
         Assert.AreEqual(Factorial(i), Mathematics.Factorial(i));
     }
 }
Пример #25
0
    private void Cut()
    {
        for (int i = 1; i < _intersectionPoints.Count; i++)
        {
            if ((_intersectionPoints[i - 1].PreviousBoundaryPoint != _intersectionPoints[i].PreviousBoundaryPoint ||
                 _intersectionPoints[i - 1].NextBoundaryPoint != _intersectionPoints[i].NextBoundaryPoint) &&
                (!Mathematics.IsVectorsAproximately(_intersectionPoints[i - 1].Pos, _intersectionPoints[i].Pos)))
            {
                if (isIntersectionLineInPolygon(_intersectionPoints[i - 1], _intersectionPoints[i]))
                {
                    List <IntersectionPoint> tempList = new List <IntersectionPoint>();
                    tempList.Add(_intersectionPoints[i - 1]);
                    tempList.Add(_intersectionPoints[i]);

                    bool cutSucceded = _cutter.Cut(_shape, _textureMat, tempList, _LM.Obstacles, out GameObject cuttedPiece);

                    if (cutSucceded)
                    {
                        _polygon = _cb.ToArray();
                        _LM.AddPieceToList(ref cuttedPiece);
                        _LM.UpdateScore();

                        if (_lastIntersectionPoint != IntersectionPoint.zero)
                        {
                            CorrectLastIntersectionPoint();
                        }
                        CorrectIntersectionPointsLeft(i + 1);
                    }
                }
            }
        }
    }
Пример #26
0
        public void UnboundLine(MyLine tempLine)
        {
            int currentModel           = this.parent.GetCurrentModelIndex();
            MyFiniteElementModel model = this.parent.currentFullModel.FiniteElementModels[currentModel];

            List <MyNode> nodes = new List <MyNode>();

            if (tempLine is MyStraightLine)
            {
                nodes = model.Nodes.FindAll(node => Mathematics.pointOnLine(node.X, node.Y, (MyStraightLine)tempLine) && model.INOUT[node.Id] != 0);
            }
            else
            {
                double precision = (model.baseType == MyFiniteElementModel.GridType.Delauney || model.type == MyFiniteElementModel.GridType.FrontalMethod) ? 0.01 : -1;
                nodes = model.Nodes.FindAll(node => Mathematics.pointFitsArc(node, (MyArc)tempLine, precision) && model.INOUT[node.Id] != 0);
            }

            foreach (MyNode node in nodes)
            {
                UnboundNode(node);
            }
            // сохраняем закрепления в массив NFIX
            renewNfixNB(currentModel);
            this.parent.DrawFEBounds(Color.Brown);

            this.txtLine.Text = "";
            this.txtLine.Select();
        }
Пример #27
0
    private void CorrectIntersectionPointsLeft(int index)
    {
        for (; index < _intersectionPoints.Count; index++)
        {
            for (int i = 1; i <= _cb.CustomBox.Count; i++)
            {
                float distanceKJ = Vector3.Distance(_intersectionPoints[index].Pos, _cb.CustomBox[i - 1].Pos);
                float distanceKI = Vector3.Distance(_intersectionPoints[index].Pos, _cb.CustomBox[i % _cb.CustomBox.Count].Pos);
                float distanceIJ = Vector3.Distance(_cb.CustomBox[i - 1].Pos, _cb.CustomBox[i % _cb.CustomBox.Count].Pos);

                if (Mathematics.IsVectorsAproximately(_intersectionPoints[index].Pos, _cb.CustomBox[i - 1].Pos))
                {
                    _intersectionPoints[index].ChangePrevNextPoints(i - 1, i - 1);
                }
                else if (Mathematics.IsVectorsAproximately(_intersectionPoints[index].Pos, _cb.CustomBox[i % _cb.CustomBox.Count].Pos))
                {
                    _intersectionPoints[index].ChangePrevNextPoints(i, i);
                }
                else if (Mathf.Approximately(distanceKI + distanceKJ, distanceIJ))
                {
                    _intersectionPoints[index].ChangePrevNextPoints(i - 1, i);
                }
            }
        }
    }
Пример #28
0
        private async Task SeedBookmarkWithMarks(PMGDbContext context)
        {
            var mathMark = new Mathematics()
            {
                Mark     = 3,
                bookmark = Bookmark,
                Day      = DateTime.UtcNow
            };

            var englishMark = new English()
            {
                Mark     = 4,
                bookmark = Bookmark,
                Day      = DateTime.UtcNow
            };

            var philosophyMark = new Philosophy()
            {
                Mark     = 5,
                bookmark = Bookmark,
                Day      = DateTime.UtcNow
            };

            context.Mathematics.Add(mathMark);
            context.Add(englishMark);
            context.Philosophy.Add(philosophyMark);

            context.SaveChanges();
        }
Пример #29
0
        protected override void Lerp(float normalizedTime)
        {
            valueX = Mathematics.LerpFloat(fromScaleX, toScaleX, normalizedTime);
            valueY = Mathematics.LerpFloat(fromScaleY, toScaleY, normalizedTime);

            transform.localScale = new Vector3(valueX, valueY, transform.localScale.z);
        }
Пример #30
0
        private EnemyModel CreateEnemyModel()
        {
            EnemyModel enemyModel = new EnemyModel();

            enemyModel.Front = new Point(0, -1);
            enemyModel.Mass  = .2f;
            enemyModel.Scale = Mathematics.Lerp(.4d, .8d, _rnd.NextDouble());

            enemyModel.MaxSpeed = (float)Mathematics.Lerp(_enemyMaxSpeedLowRange, _enemyMaxSpeedHighRange, _rnd.NextDouble());
            enemyModel.MaxForce = (float)Mathematics.Lerp(_enemyMaxForceLowRange, _enemyMaxForceHighRange, _rnd.NextDouble());

            int quadrant = _rnd.Next(1, 5);

            switch (quadrant)
            {
            case 1:
                enemyModel.Position = new Point(_rnd.NextDouble() * Width, -_enemyCreationBufferWidth);
                break;

            case 2:
                enemyModel.Position = new Point(Width + _enemyCreationBufferWidth, _rnd.NextDouble() * Height);
                break;

            case 3:
                enemyModel.Position = new Point(_rnd.NextDouble() * Width, Width + _enemyCreationBufferWidth);
                break;

            default:
                enemyModel.Position = new Point(-_enemyCreationBufferWidth, _rnd.NextDouble() * Height);
                break;
            }
            enemyModel.Initialize();
            return(enemyModel);
        }
 /// <summary>
 /// Clears a render target.
 /// </summary>
 /// <param name="renderTarget">The render target.</param>
 /// <param name="color">Set this color value for the RenderTarget buffer.</param>
 public void Clear(RenderTarget renderTarget, Mathematics.Color color)
 {
     throw new NotImplementedException();
 }
Пример #32
0
 /// <summary>	
 /// <p> Sets all the elements in a render target to one value. </p>	
 /// </summary>	
 /// <param name="renderTargetView"><dd>  <p> Specifies a <see cref="SharpDX.Direct3D12.CpuDescriptorHandle"/> structure that describes the CPU descriptor handle that represents the start of the heap for the render target to be cleared. </p> </dd></param>	
 /// <param name="colorRGBA"><dd>  <p> A 4-component array that represents the color to fill the render target with. </p> </dd></param>	
 /// <param name="numRects"><dd>  <p> The number of rectangles in the array that the <em>pRects</em> parameter specifies. </p> </dd></param>	
 /// <param name="rectsRef"><dd>  <p> An array of <strong>D3D12_RECT</strong> structures for the rectangles in the resource view to clear. If <strong><c>null</c></strong>, <strong>ClearRenderTargetView</strong> clears the entire resource view. </p> </dd></param>	
 /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::ClearRenderTargetView']/*"/>	
 /// <msdn-id>dn903842</msdn-id>	
 /// <unmanaged>void ID3D12GraphicsCommandList::ClearRenderTargetView([In] D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView,[In] const SHARPDX_COLOR4* ColorRGBA,[In] unsigned int NumRects,[In, Buffer] const RECT* pRects)</unmanaged>	
 /// <unmanaged-short>ID3D12GraphicsCommandList::ClearRenderTargetView</unmanaged-short>	
 public void ClearRenderTargetView(CpuDescriptorHandle renderTargetView, Mathematics.Interop.RawColor4 colorRGBA)
 {
     ClearRenderTargetView(renderTargetView, colorRGBA, 0, null);
 }
 /// <summary>	
 /// <p>Set the blend state of the output-merger stage.</p>	
 /// </summary>	
 /// <param name="blendState"><dd>  <p>Pointer to a blend-state interface (see <strong><see cref="SharpDX.Direct3D11.BlendState"/></strong>). Passing in <strong><c>null</c></strong> implies a default blend state. See remarks for further details.</p> </dd></param>
 /// <param name="blendFactor"><dd>  <p>Array of blend factors, one for each RGBA component. This requires a blend state object that specifies the <strong><see cref="SharpDX.Direct3D11.BlendOption.BlendFactor"/></strong> option.</p> </dd></param>	
 /// <param name="multiSampleMask"><dd>  <p>32-bit sample coverage. The default value is 0xffffffff. See remarks.</p> </dd></param>	
 /// <remarks>	
 /// <p>Blend state is used by the output-merger stage to determine how to blend together two pixel values. The two values are commonly the current pixel value and the pixel value already in the output render target. Use the <strong>blend operation</strong> to control where the two pixel values come from and how they are mathematically combined.</p><p>To create a blend-state interface, call <strong><see cref="SharpDX.Direct3D11.Device.CreateBlendState"/></strong>.</p><p>Passing in <strong><c>null</c></strong> for the blend-state interface indicates to the runtime to set a default blending state.  The following table indicates the default blending parameters.</p><table> <tr><th>State</th><th>Default Value</th></tr> <tr><td>AlphaToCoverageEnable</td><td><strong><see cref="SharpDX.Result.False"/></strong></td></tr> <tr><td>BlendEnable</td><td><strong><see cref="SharpDX.Result.False"/></strong>[8]</td></tr> <tr><td>SrcBlend</td><td><see cref="SharpDX.Direct3D11.BlendOption.One"/></td></tr> <tr><td>DstBlend</td><td><see cref="SharpDX.Direct3D11.BlendOption.Zero"/></td></tr> <tr><td>BlendOp</td><td><see cref="SharpDX.Direct3D11.BlendOperation.Add"/></td></tr> <tr><td>SrcBlendAlpha</td><td><see cref="SharpDX.Direct3D11.BlendOption.One"/></td></tr> <tr><td>DstBlendAlpha</td><td><see cref="SharpDX.Direct3D11.BlendOption.Zero"/></td></tr> <tr><td>BlendOpAlpha</td><td><see cref="SharpDX.Direct3D11.BlendOperation.Add"/></td></tr> <tr><td>RenderTargetWriteMask[8]</td><td><see cref="SharpDX.Direct3D11.ColorWriteMaskFlags.All"/>[8]</td></tr> </table><p>?</p><p>A sample mask determines which samples get updated in all the active render targets. The mapping of bits in a sample mask to samples in a multisample render target is the responsibility of an individual application. A sample mask is always applied; it is independent of whether multisampling is enabled, and does not depend on whether an application uses multisample render targets.</p><p> The method will hold a reference to the interfaces passed in. This differs from the device state behavior in Direct3D 10. </p>	
 /// </remarks>	
 public void SetBlendState(BlendState blendState, Mathematics.Color blendFactor, uint multiSampleMask = 0xFFFFFFFF)
 {
     throw new NotImplementedException();
 }
Пример #34
0
 public Polinom(Alphabets.Alphabet alphabet, Mathematics.Function function)
 {
     this.alphabet = alphabet;
     this.function = function;
 }