Example #1
0
        /// <summary>
        /// This blend is better for incremental blends since it will also blend the moving target and forces
        /// instead of using the target state values for these items as the other blend function does (our animations
        /// are setup this old way and cannot be changed now).
        /// </summary>
        /// <param name="targetState"></param>
        /// <param name="blendFactor"></param>
        public void incrementalBlend(MusclePosition targetState, float blendFactor)
        {
            float modifiedBlendFactor = blendFactor;

            if (blendFactor < 1.0f)
            {
                EasingFunctions.Ease(targetState.Easing, 0, 1, blendFactor, 1);
            }

            if (MuscleController.MovingTarget != null) //If this is null then the whole mandible simulation is invalid and its better to do nothing
            {
                MuscleController.changeForce("MovingMuscleDynamic", NumberFunctions.lerp(muscleForce, targetState.muscleForce, modifiedBlendFactor));
                MuscleController.MovingTarget.Offset = movingTargetPosition.lerp(ref targetState.movingTargetPosition, ref modifiedBlendFactor);

                ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP");
                float delta = targetState.leftCPPosition - leftCPPosition;
                leftCP.setLocation(leftCPPosition + delta * modifiedBlendFactor);

                ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP");
                delta = targetState.rightCPPosition - rightCPPosition;
                rightCP.setLocation(rightCPPosition + delta * modifiedBlendFactor);
            }

            FKRoot pelvis;

            if (pelvisChainState != null && targetState.pelvisChainState != null && PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis))
            {
                //This creates garbage, but it is unknown if this has negative effects
                FKChainState blendedState = new FKChainState();
                blendedState.setToBlendOf(pelvisChainState, targetState.pelvisChainState, modifiedBlendFactor);
                pelvis.applyChainState(blendedState);
            }
        }
Example #2
0
        internal void instantlyApplyBlended(List <TransparencyInterface> unvisitedInterfaces, float endAlphaValue, float percent)
        {
            TransparencyInterface obj = TransparencyController.getTransparencyObject(transparencyObject);

            if (obj != null)
            {
                obj.CurrentAlpha = NumberFunctions.lerp(alphaValue, endAlphaValue, percent);
                unvisitedInterfaces.Remove(obj);
            }
        }
Example #3
0
        public int DetMod(int prime_number)
        {
            IntegerSquareMatrix triangleMatrix = new IntegerSquareMatrix(Rows, elements);
            int signOfDet = 0;

            for (int i = 0; i < triangleMatrix.Rows; i++)
            {
                for (int j = i; j < triangleMatrix.Columns; j++)
                {
                    if (triangleMatrix[j, i] != 0)
                    {
                        int reverselement = NumberFunctions.GetMulInverse(triangleMatrix[j, i], prime_number);
                        for (int k = j; k < triangleMatrix.Columns; k++)
                        {
                            triangleMatrix[j, k] *= reverselement;
                            triangleMatrix[j, k] %= prime_number;
                        }
                        if (i != j)
                        {
                            triangleMatrix = triangleMatrix.SwapLine(j, i);
                            signOfDet++;
                            signOfDet %= 2;                                            //ОПРЕДЕЛЯЮ ЗНАК det
                        }
                        for (int k = j + 1; k < triangleMatrix.Columns; k++)
                        {
                            while (triangleMatrix[k, j] != 0)
                            {
                                if (triangleMatrix[k, j] > 0)
                                {
                                    triangleMatrix = triangleMatrix.SubtractionOfLines(k, j);
                                }
                                else
                                {
                                    triangleMatrix = triangleMatrix.AdditionOfLines(k, j);
                                }
                            }
                        }
                    }
                }
            }
            int det = 1;

            for (int i = 0; i < triangleMatrix.Columns; i++)
            {
                det *= triangleMatrix[i, i];
            }
            if (signOfDet == 0)
            {
                return(det);
            }
            else
            {
                return(-1 * det);
            }
        }
        public void AddNumbers_TwoNumbers()
        {
            // Arrange
            double[] numbers = { 1, 2 };
            NumberFunctions nf = new NumberFunctions();

            // Act
            var result = nf.AddNumbers(numbers);

            // Assert
            Assert.AreEqual(numbers.Sum(), result);
        }
        public void AddNumbers_TenNumbersWithPositiveAndNegatives()
        {
            // Arrange
            double[] numbers = { 1, -2, 3, 4, -5, 6, 7, -8, 9, 10 };
            NumberFunctions nf = new NumberFunctions();

            // Act
            var result = nf.AddNumbers(numbers);

            // Assert
            Assert.AreEqual(numbers.Sum(), result);
        }
 public void nextNegative(int min, int max, IPromise promise)
 {
     try
     {
         var range    = max - min;
         var random   = min + (RNG.Next() % range);
         var numFuncs = new NumberFunctions();
         promise.Resolve(numFuncs.MakeNegative(random));
     }
     catch (Exception e)
     {
         promise.Reject(e.Message, new Java.Lang.Exception(e.Message));
     }
 }
Example #7
0
 private static int computeSize(int dimension)
 {
     if (dimension > MAX_TEXTURE_SIZE_POW2)
     {
         return(MAX_TEXTURE_SIZE_POW2);
     }
     else if (dimension < MIN_TEXTURE_SIZE_POW2)
     {
         return(MIN_TEXTURE_SIZE_POW2);
     }
     else
     {
         return(NumberFunctions.computeClosestLargerPow2(dimension, 256));
     }
 }
Example #8
0
        public IntegerSquareMatrix ToTopTriangleMatrixModPrime(int primeNumber, int degree)
        {
            IntegerSquareMatrix triangleMatrix = new IntegerSquareMatrix(Rows, elements);
            int sign_of_det  = 0;
            int primeNumber1 = Convert.ToInt32(Math.Pow(primeNumber, degree));

            for (int i = 0; i < triangleMatrix.Rows; i++)
            {
                for (int j = i; j < triangleMatrix.Columns; j++)
                {
                    if (triangleMatrix[j, i] != 0)
                    {
                        int reverselement = NumberFunctions.GetMulInverse(triangleMatrix[j, i], primeNumber1);
                        for (int k = j; k < triangleMatrix.Columns; k++)
                        {
                            triangleMatrix[j, k] *= reverselement;
                            triangleMatrix[j, k] %= primeNumber1;
                        }
                        if (i != j)
                        {
                            triangleMatrix = triangleMatrix.SwapLine(j, i);
                            sign_of_det++;
                            sign_of_det %= 2;                                            //ОПРЕДЕЛЯЮ ЗНАК det
                        }
                        for (int k = j + 1; k < triangleMatrix.Columns; k++)
                        {
                            while (triangleMatrix[k, j] != 0)
                            {
                                if (triangleMatrix[k, j] > 0)
                                {
                                    triangleMatrix = triangleMatrix.SubtractionOfLines(k, j);
                                }
                                else
                                {
                                    triangleMatrix = triangleMatrix.AdditionOfLines(k, j);
                                }
                            }
                        }
                    }
                }
            }
            return(triangleMatrix);
        }
Example #9
0
 public NumericExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     Debug.Assert(
         op == Operator.Op.PLUS || op == Operator.Op.MINUS ||
         op == Operator.Op.MUL || op == Operator.Op.DIV ||
         op == Operator.Op.MOD
     );
     Debug.Assert(opnd1 != null && opnd2 != null);
     if (opnd1.StaticType != XPathResultType.Number)
     {
         opnd1 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd1);
     }
     if (opnd2.StaticType != XPathResultType.Number)
     {
         opnd2 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd2);
     }
     _op = op;
     _opnd1 = opnd1;
     _opnd2 = opnd2;
 }
 private NumberFunctions(NumberFunctions other) : base(other) {
     this.arg = Clone(other.arg);
     this.ftype = other.ftype;
 }
 public void AddNumbers_NullParameterNumbers()
 {
     // Arrange / Act / Assert
     NumberFunctions nf = new NumberFunctions();
     var result = nf.AddNumbers(null);
 }
 public void AddNumbers_EmptyArrayNumbers()
 {
     // Arrange / Act / Assert
     NumberFunctions nf = new NumberFunctions();
     var result = nf.AddNumbers(new double[] { });
 }
Example #13
0
 private NumberFunctions(NumberFunctions other) : base(other)
 {
     _arg = Clone(other._arg);
     _ftype = other._ftype;
 }
Example #14
0
 public void blend(float percent)
 {
     FingerSection.setOrientation(NumberFunctions.lerp(startYaw, yaw, percent), NumberFunctions.lerp(startPitch, pitch, percent));
 }
Example #15
0
        public async Task OnGetAsync(
            string sortOrder,
            string make,
            string model,
            string min_price,
            string max_price,
            string min_budget,
            string max_budget,
            string mileage,
            string transmission,
            string fuel_type,
            string body_type,
            int?pageIndex
            )
        {
            //Select Lists
            BodyTypes = await _context.StocklistImport
                        .Select(
                s => new SelectListItem
            {
                Value    = s.BodyType,
                Text     = s.BodyType,
                Selected = s.BodyType == body_type
            }
                )
                        .Distinct()
                        .ToListAsync();

            Makes = await _context.StocklistImport
                    .Select(
                s => new SelectListItem
            {
                Value    = s.Make,
                Text     = s.Make,
                Selected = s.Make == make
            }
                )
                    .Distinct()
                    .ToListAsync();

            ModelMakes = await _context.StocklistImport
                         .Select(
                s => new SelectListGroup
            {
                Name = s.Make
            }
                )
                         .Distinct()
                         .ToListAsync();

            Models = (await _context.StocklistImport
                      .ToListAsync())
                     .GroupBy(grp => new { grp.Make, grp.Model, grp.BodyType })
                     .Select(
                s => new SelectListItem
            {
                Value = s.Key.Model,
                Text  = s.Key.Model + " (" + s.Key.BodyType + ")",
                Group = ModelMakes.SingleOrDefault(m => m.Name == s.Key.Make)
            }
                )
                     .OrderBy(s => s.Group.Name)
                     .ThenBy(s => s.Text)
                     .ToList();

            MinPrice  = NumberFunctions.CurrencyToInt(min_price);
            MaxPrice  = NumberFunctions.CurrencyToInt(max_price);
            MinBudget = NumberFunctions.CurrencyToInt(min_budget);
            MaxBudget = NumberFunctions.CurrencyToInt(max_budget);

            //Add a default sort order
            if (sortOrder == null)
            {
                sortOrder = "Recent";
            }

            CurrentSortID = sortOrder;
        }
Example #16
0
 public void AddNumbersTest()
 {
     Assert.AreEqual(10, NumberFunctions.AddNumbers(5, 5));
 }