System.Math.Pow(double, double)

Here are the examples of the csharp api System.Math.Pow(double, double) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4546 Examples 7

19 View Source File : Player_Xp.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

private double VitaeCPPoolThreshold(float vitae, int level)
        {
            return (Math.Pow(level, 2.5) * 2.5 + 20.0) * Math.Pow(vitae, 5.0) + 0.5;
        }

19 View Source File : Main.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence

public void CallToChange(double x, double y, double z, double t)
        {
            //Dont forget to set the following outside of this function. 
            //VariableFunctionContainer.FunctionCoEfficientList = new List<Func<double, double, double, double, double>>()
               
            container = new SimpleFunctionContainer((u, v) => VariableFunctionContainer.GetCurrentValue(1,x,y,z,t)*(u) + VariableFunctionContainer.GetCurrentValue(2, x, y, z, t) * (Math.Pow(u,2)), 8, 8, 20);
            //container = new SimpleFunctionContainer((u, v) => (u*(1-u) - Math.Pow(v,2))/(Math.Pow((u - 1),2) + Math.Pow(v, 2)) * 200  + 200, 8, 8, 20);
            //container = new SimpleFunctionContainer((u, v) => (Math.Pow(Math.Cos(u), 5) * v - Math.Pow(v, 5) * u) / 3900000, 8, 8, 20);
            vectorPointsList = container.VectorPointsList;
        }

19 View Source File : ViewModel3DFactory.cs
License : MIT License
Project Creator : ABTSoftware

private static WaterfallDataSeries3D<double> GereplacederfallDataSeries()
        {
            var pointsPerSlice = 100;
            var sliceCount = 20;

            var logBase = 10;
            var slicePositions = new double[sliceCount];
            for (int i = 0; i < sliceCount; ++i)
            {
                slicePositions[i] = i;
            }

            var dataSeries = new WaterfallDataSeries3D<double>(pointsPerSlice, slicePositions);
            dataSeries.StartX = 10;
            dataSeries.StepX = 1;

            _transform.init((uint)Math.Log(pointsPerSlice, 2));

            var count = pointsPerSlice * 2;
            var re = new double[count];
            var im = new double[count];

            for (int sliceIndex = 0; sliceIndex < sliceCount; ++sliceIndex)
            {
                for (var i = 0; i < count; i++)
                {
                    re[i] = 2.0 * Math.Sin(2 * Math.PI * i / 20) +
                            5 * Math.Sin(2 * Math.PI * i / 10) +
                            2.0 * _random.NextDouble();
                    im[i] = -10;
                }

                _transform.run(re, im);

                var scaleCoef = Math.Pow(1.5, sliceIndex * 0.3) / Math.Pow(1.5, sliceCount * 0.3);
                for (var pointIndex = 0; pointIndex < pointsPerSlice; pointIndex++)
                {
                    var mag = Math.Sqrt(re[pointIndex] * re[pointIndex] + im[pointIndex] * im[pointIndex]);
                    var yVal = _random.Next(10, 20) * Math.Log10(mag / pointsPerSlice);
                    yVal = (yVal < -25 || yVal > -5)
                        ? (yVal < -25) ? -25 : _random.Next(-6, -3)
                        : yVal;

                    dataSeries[sliceIndex, pointIndex] = -yVal * scaleCoef;
                }
            }

            return dataSeries;
        }

19 View Source File : Scenery.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static float ScaleObj(ObjectDesc obj, uint x, uint y, uint k)
        {
            var scale = 1.0f;

            var minScale = obj.MinScale;
            var maxScale = obj.MaxScale;

            if (minScale == maxScale)
                scale = maxScale;
            else
                scale = (float)(Math.Pow(maxScale / minScale,
                    (1813693831 * y - (k + 32593) * (1360117743 * y * x + 1888038839) - 1109124029 * x) * 2.3283064e-10) * minScale);

            return scale;
        }

19 View Source File : LinearToLogarithmicValueConverter.cs
License : MIT License
Project Creator : ABTSoftware

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is IConvertible convertible)
            {
                return Math.Pow(LogarithmicBase, convertible.ToDouble(CultureInfo.InvariantCulture));
            }

            return value;
        }

19 View Source File : RabbitMqPresistentConnection.cs
License : MIT License
Project Creator : Abdulrhman5

public bool TryConnect()
        {
            _logger.LogInformation("RabbitMQ Client is trying to connect");

            lock (sync_root)
            {
                var policy = RetryPolicy.Handle<SocketException>()
                    .Or<BrokerUnreachableException>()
                    .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
                    {
                        _logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s ({ExceptionMessage})", $"{time.TotalSeconds:n1}", ex.Message);
                    }
                );

                policy.Execute(() =>
                {
                    _connection = _connectionFactory
                          .CreateConnection();
                });

                if (IsConnected)
                {
                    _connection.ConnectionShutdown += OnConnectionShutdown;
                    _connection.CallbackException += OnCallbackException;
                    _connection.ConnectionBlocked += OnConnectionBlocked;

                    _logger.LogInformation("RabbitMQ Client acquired a persistent connection to '{HostName}' and is subscribed to failure events", _connection.Endpoint.HostName);

                    return true;
                }
                else
                {
                    _logger.LogCritical("FATAL ERROR: RabbitMQ connections could not be created and opened");

                    return false;
                }
            }
        }

private static void GammaDistributionFit(IList<decimal> points)
        {
            var sum = 0m;
            var sumxLNx = 0m;
            var sumLNx = 0m;
            int n = points.Count();
            foreach (var d in points)
            {
                sum += d;
                sumxLNx += d * ((decimal)Math.Log((double)d));
                sumLNx += (decimal)Math.Log((double)d);
            }

            k = ((n * sum) / ((n * sumxLNx) - (sumLNx * sum)));
            α = (decimal)((1 / (Math.Pow((double)n, 2))) * (double)((n * sumxLNx) - (sumLNx * sum)));
        }

19 View Source File : GameTest.cs
License : MIT License
Project Creator : 734843327

public Vector2d changeCoordinateSystem(Vector2d point, float angle)
    {
        Vector2d result;
        double deltaX;
        double deltaY;
        angle = angle * 3.14159265f / 180;//角度化弧度
        deltaX = point.y * Mathd.Cos(angle) + point.x * Mathd.Sin(angle);
        deltaY = point.x * Mathd.Cos(angle) - point.y * Mathd.Sin(angle);
        //Debug.Log("delta:" + deltaX.ToString() + "   " + deltaY.ToString());
        result.y = deltaX / Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
        result.x = deltaY / Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
        return result;
    }

public static double Variance(IList<double> observations)
        {
            var mean = Mean(observations);
            int n = observations.Count() - 1;
            var result = 0d;
            var sum = 0d;
            foreach (var d in observations)
            {
                sum += Math.Pow((d - mean), 2);
            }
            result = sum / n;
            return result;
        }

19 View Source File : AccelCalculator.cs
License : MIT License
Project Creator : a1xd

public void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection<SimulatedMouseInput> simulatedInputData)
        {
            double lastInputMagnitude = 0;
            double lastOutputMagnitude = 0;
            SimulatedMouseInput lastInput;
            double lastSlope = 0;

            double maxRatio = 0.0;
            double minRatio = Double.MaxValue;
            double maxSlope = 0.0;
            double minSlope = Double.MaxValue;

            double log = -2;
            int index = 0;
            int logIndex = 0;

            foreach (var simulatedInputDatum in simulatedInputData)
            {
                if (simulatedInputDatum.velocity <= 0)
                {
                    continue;
                }

                var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, 1, simulatedInputDatum.time);
                var outMagnitude = DecimalCheck(Velocity(output.Item1, output.Item2, simulatedInputDatum.time));
                var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5);
                var outDiff = Math.Round(outMagnitude - lastOutputMagnitude, 5);

                if (inDiff == 0)
                {
                    continue;
                }

                if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
                {
                    data.VelocityPoints.Add(simulatedInputDatum.velocity, outMagnitude);
                }
                else
                {
                    continue;
                }

                while (Math.Pow(10,log) < outMagnitude && logIndex < data.LogToIndex.Length)
                {
                    data.LogToIndex[logIndex] = index;
                    log += 0.01;
                    logIndex++;
                }

                var ratio = DecimalCheck(outMagnitude / simulatedInputDatum.velocity);
                var slope = DecimalCheck(inDiff > 0 ? outDiff / inDiff : starter);

                if (slope < lastSlope)
                {
                    Console.WriteLine();
                }

                if (ratio > maxRatio)
                {
                    maxRatio = ratio;
                }

                if (ratio < minRatio)
                {
                    minRatio = ratio;
                }

                if (slope > maxSlope)
                {
                    maxSlope = slope;
                }

                if (slope < minSlope)
                {
                    minSlope = slope;
                }

                if (!data.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
                {
                    data.AccelPoints.Add(simulatedInputDatum.velocity, ratio);
                }

                if (!data.GainPoints.ContainsKey(simulatedInputDatum.velocity))
                {
                    data.GainPoints.Add(simulatedInputDatum.velocity, slope);
                }

                lastInputMagnitude = simulatedInputDatum.velocity;
                lastOutputMagnitude = outMagnitude;
                index += 1;
                lastInput = simulatedInputDatum;
                lastSlope = slope;
            }

            index--;

            while (log <= 5.0)
            {
                data.LogToIndex[logIndex] = index;
                log += 0.01;
                logIndex++;
            }

            data.MaxAccel = maxRatio;
            data.MinAccel = minRatio;
            data.MaxGain = maxSlope;
            data.MinGain = minSlope;
        }

19 View Source File : FloatExtensions.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static float Truncate(this float num, int decimalPlaces)
        {
            var multiplier = Math.Pow(10, decimalPlaces);

            return (float)(Math.Truncate(num * multiplier) / multiplier);
        }

19 View Source File : DoubleAxisAsDateTimeAxis.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void FillDataSeries(WaterfallDataSeries3D<double> dataSeries, int sliceCount, int pointsPerSlice)
        {
            for (int sliceIndex = 0; sliceIndex < sliceCount; ++sliceIndex)
            {
                var scaleCoef = Math.Pow(1.5, sliceIndex * 0.3) / Math.Pow(1.5, sliceCount * 0.3);
                for (var pointIndex = 0; pointIndex < pointsPerSlice; pointIndex++)
                {
                    dataSeries[sliceIndex, pointIndex] = (Math.Sin(10 * Math.PI * pointIndex / pointsPerSlice) + 1.0) * scaleCoef;
                }
            }
        }

19 View Source File : OCIncident.cs
License : Apache License 2.0
Project Creator : AantCoder

public static int CalculateRaidCost(string type, long serverId, int mult, string arrivalModes, string faction)
        {
            Loger.Log("IncidentLod OCIncident.CalculateRaidCost 1");
            //var serverId = UpdateWorldController.GetServerInfo(wo).ServerId;
            var target = UpdateWorldController.GetOtherByServerId(serverId) as BaseOnline;
            if (target == null) return -1;            
            var costs = target.Player.CostWorldObjects(serverId);
            var cost = costs.MarketValue + costs.MarketValuePawn;
            if (cost <= 0) return -1;

            //{цена поселения защитника/100 000}^(2/3) * 100 * lvl ^(3/2)
            var raidCost = (int)((float)Math.Pow(cost / 100000f, 2f / 3f) * 100f 
                * (float)Math.Pow((float)mult, 3f / 2f) //* (float)mult
                * (float)SessionClientController.Data.GeneralSettings.IncidentCostPrecent / 100f
                * (type == "inf" ? 3f 
                    : type == "acid" ? 2f
                    : type == "raid" 
                    ?   (arrivalModes == "random" ? 1.5f : arrivalModes == "air" ? 1.4f : 1f)
                      * (faction == "mech" ? 5f : faction == "pirate" ? 2f : 1f)
                    : 1f)
                );

            Loger.Log($"IncidentLod OCIncident.CalculateRaidCost({serverId}, {mult}). targetCost={(int)cost} raidCost={raidCost}");

            return SessionClientController.Data.IsAdmin && Prefs.DevMode ? 1 : raidCost;
        }

19 View Source File : Trajectory.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static int SolveCubic(double c0, double c1, double c2, double c3, out double s0, out double s1, out double s2)
        {
            s0 = double.NaN;
            s1 = double.NaN;
            s2 = double.NaN;

            int num;
            double sub;
            double A, B, C;
            double sq_A, p, q;
            double cb_p, D;

            /* normal form: x^3 + Ax^2 + Bx + C = 0 */
            A = c1 / c0;
            B = c2 / c0;
            C = c3 / c0;

            /*  subsreplacedute x = y - A/3 to eliminate quadric term:  x^3 +px + q = 0 */
            sq_A = A * A;
            p = 1.0 / 3 * (-1.0 / 3 * sq_A + B);
            q = 1.0 / 2 * (2.0 / 27 * A * sq_A - 1.0 / 3 * A * B + C);

            /* use Cardano's formula */
            cb_p = p * p * p;
            D = q * q + cb_p;

            if (IsZero(D))
            {
                if (IsZero(q)) /* one triple solution */
                {
                    s0 = 0;
                    num = 1;
                }
                else /* one single and one double solution */
                {
                    double u = Math.Pow(-q, 1.0 / 3.0);
                    s0 = 2 * u;
                    s1 = -u;
                    num = 2;
                }
            }
            else if (D < 0) /* Casus irreducibilis: three real solutions */
            {
                double phi = 1.0 / 3 * Math.Acos(-q / Math.Sqrt(-cb_p));
                double t = 2 * Math.Sqrt(-p);

                s0 = t * Math.Cos(phi);
                s1 = -t * Math.Cos(phi + Math.PI / 3);
                s2 = -t * Math.Cos(phi - Math.PI / 3);
                num = 3;
            }
            else /* one real solution */
            {
                double sqrt_D = Math.Sqrt(D);
                double u = Math.Pow(sqrt_D - q, 1.0 / 3.0);
                double v = -Math.Pow(sqrt_D + q, 1.0 / 3.0);

                s0 = u + v;
                num = 1;
            }

            /* resubsreplacedute */
            sub = 1.0 / 3 * A;

            if (num > 0) s0 -= sub;
            if (num > 1) s1 -= sub;
            if (num > 2) s2 -= sub;

            return num;
        }

19 View Source File : Mathd.cs
License : MIT License
Project Creator : 734843327

public static double Pow(double d, double p) {
            return Math.Pow(d, p);
        }

19 View Source File : BackoffTimerHelper.cs
License : MIT License
Project Creator : actions

public static TimeSpan GetExponentialBackoff(
            Int32 attempt,
            TimeSpan minBackoff,
            TimeSpan maxBackoff,
            TimeSpan deltaBackoff)
        {
            Double randomBackoff = (Double)new Random().Next((Int32)(deltaBackoff.TotalMilliseconds * 0.8), (Int32)(deltaBackoff.TotalMilliseconds * 1.2));
            Double additionalBackoff = attempt < 0 ? (Math.Pow(2.0, (Double)attempt)) * randomBackoff : (Math.Pow(2.0, (Double)attempt) - 1.0) * randomBackoff;
            return TimeSpan.FromMilliseconds(Math.Min(minBackoff.TotalMilliseconds + additionalBackoff, maxBackoff.TotalMilliseconds));
        }

19 View Source File : CreateAWaterfall3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void FillDataSeries(WaterfallDataSeries3D<double> dataSeries, int sliceCount, int pointsPerSlice)
        {
            var count = pointsPerSlice * 2;
            var re = new double[count];
            var im = new double[count];

            for (int sliceIndex = 0; sliceIndex < sliceCount; ++sliceIndex)
            {
                for (var i = 0; i < count; i++)
                {
                    re[i] = 2.0 * Math.Sin(2 * Math.PI * i / 20) +
                            5 * Math.Sin(2 * Math.PI * i / 10) +
                            2.0 * _random.NextDouble();
                    im[i] = -10;
                }

                _transform.run(re, im);

                var scaleCoef = Math.Pow(1.5, sliceIndex * 0.3) / Math.Pow(1.5, sliceCount * 0.3);
                for (var pointIndex = 0; pointIndex < pointsPerSlice; pointIndex++)
                {
                    var mag = Math.Sqrt(re[pointIndex] * re[pointIndex] + im[pointIndex] * im[pointIndex]);
                    var yVal = _random.Next(10,20) * Math.Log10(mag / pointsPerSlice);
                    yVal = (yVal < -25 || yVal > -5)
                        ? (yVal < -25) ? -25 : _random.Next(-6, -3)
                        : yVal;

                    dataSeries[sliceIndex, pointIndex] = -yVal * scaleCoef;
                }
            }
        }

19 View Source File : BondHalfYearly.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence

private static decimal discountFactorValue(decimal yieldRate, decimal term)
        {
            var discountFactor = Math.Pow((1 / (double)(1 + yieldRate)), (double)(term));
            return (decimal)discountFactor;
        }

19 View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099

public string GetMySqlEnumSetDefine()
	{
		if (fsql.Ado.DataType != FreeSql.DataType.MySql && fsql.Ado.DataType != FreeSql.DataType.OdbcMySql) return null;
		var sb = new StringBuilder();
		foreach (var col in table.Columns)
		{
			if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Enum || col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set)
			{
				if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set) sb.Append("\r\n\t[Flags]");
				sb.Append($"\r\n\tpublic enum {this.GetCsName(this.FullTableName)}{this.GetCsName(col.Name).ToUpper()}");
				if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set) sb.Append(" : long");
				sb.Append(" {\r\n\t\t");

				string slkdgjlksdjg = "";
				int field_idx = 0;
				int unknow_idx = 0;
				string exp2 = string.Concat(col.DbTypeTextFull);
				int quote_pos = -1;
				while (true)
				{
					int first_pos = quote_pos = exp2.IndexOf('\'', quote_pos + 1);
					if (quote_pos == -1) break;
					while (true)
					{
						quote_pos = exp2.IndexOf('\'', quote_pos + 1);
						if (quote_pos == -1) break;
						int r_cout = 0;
						//for (int p = 1; true; p++) {
						//	if (exp2[quote_pos - p] == '\\') r_cout++;
						//	else break;
						//}
						while (exp2[++quote_pos] == '\'') r_cout++;
						if (r_cout % 2 == 0/* && quote_pos - first_pos > 2*/)
						{
							string str2 = exp2.Substring(first_pos + 1, quote_pos - first_pos - 2).Replace("''", "'");
							if (Regex.IsMatch(str2, @"^[\u0391-\uFFE5a-zA-Z_\$][\u0391-\uFFE5a-zA-Z_\$\d]*$"))
								slkdgjlksdjg += ", " + str2;
							else
								slkdgjlksdjg += string.Format(@", 
/// <summary>
/// {0}
/// </summary>
[Description(""{0}"")]
Unknow{1}", str2.Replace("\"", "\\\""), ++unknow_idx);
							if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set)
								slkdgjlksdjg += " = " + Math.Pow(2, field_idx++);
							if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Enum && field_idx++ == 0)
								slkdgjlksdjg += " = 1";
							break;
						}
					}
					if (quote_pos == -1) break;
				}
				sb.Append(slkdgjlksdjg.Substring(2).TrimStart('\r', '\n', '\t'));
				sb.Append("\r\n\t}");
			}
		}
		return sb.ToString();
	}

19 View Source File : Annuity.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence

private decimal discountFactor(decimal yield, decimal term)
        {
            var d = (1 / (1 + yield));
            var dp = Math.Pow((double)d, (double)term);
            return (decimal)dp;
        }

19 View Source File : UseChartModifiers3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            var xyzDataSeries3D = new XyzDataSeries3D<double>();

            const int count = 25;
            double step = 0.3;
            var random = new Random(0);

            Color color;

            for (int x = 0; x < count; x++)
            {
                // Color is applied to PointMetadata3D and overrides the default ScatterRenderableSeries.Stroke property
                color = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
                
                for (int z = 1; z < count; z++)
                {
                    var y = (z != 0) ? Math.Pow((double) z, step) : Math.Pow((double) z + 1, 0.3);

                    xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(color, 2));
                }
            }

            ScatterSeries3D.DataSeries = xyzDataSeries3D;
        }

19 View Source File : SplineLineRenderableSeries.cs
License : MIT License
Project Creator : ABTSoftware

public override HitTestInfo HitTest(Point rawPoint, double hitTestRadius, bool interpolate = false)
            {
                var nearestBaseHitResult = base.HitTest(rawPoint, hitTestRadius, interpolate);

                // No spline? Fine - return base implementation
                if (!RenderableSeries.IsSplineEnabled || RenderableSeries._splineSeries == null || RenderableSeries.CurrentRenderPreplacedData == null)
                    return nearestBaseHitResult;

                var nearestHitResult = new HitTestInfo();

                // Get the coordinateCalculators. See 'Converting Pixel Coordinates to Data Coordinates' doreplacedentation for coordinate transforms
                var xCalc = RenderableSeries.CurrentRenderPreplacedData.XCoordinateCalculator;

                // Compute the X,Y data value at the mouse location
                var xDataPointAtMouse = xCalc.GetDataValue(RenderableSeries.CurrentRenderPreplacedData.IsVerticalChart ? rawPoint.Y : rawPoint.X);

                // Find the index in the spline interpolated data that is nearest to the X-Data point at mouse
                // NOTE: This replacedumes the data is sorted in ascending direction and a binary search would be faster ... 
                int foundIndex = RenderableSeries.FindIndex(RenderableSeries._splineSeries, xDataPointAtMouse);

                if (foundIndex != -1)
                {
                    nearestHitResult.IsWithinDataBounds = true;

                    // Find the nearest data point to the mouse 
                    var xDataPointNearest = RenderableSeries._splineSeries[foundIndex].X;
                    var yDataPointNearest = RenderableSeries._splineSeries[foundIndex].Y;
                    nearestHitResult.XValue = xDataPointNearest;
                    nearestHitResult.YValue = yDataPointNearest;

                    // Compute the X,Y coordinates (pixel coords) of the nearest data point to the mouse
                    nearestHitResult.HitTestPoint = nearestHitResult.HitTestPoint = RenderableSeries.GetCoordinatesFor(xDataPointNearest, yDataPointNearest);

                    // Determine if mouse-location is within 7.07 pixels of the nearest data point
                    var distance = Math.Pow(rawPoint.X - nearestHitResult.HitTestPoint.X, 2) +
                                   Math.Pow(rawPoint.Y - nearestHitResult.HitTestPoint.Y, 2);
                    distance = Math.Sqrt(distance);

                    var baseDistance = Math.Pow(rawPoint.X - nearestBaseHitResult.HitTestPoint.X, 2) +
                                       Math.Pow(rawPoint.Y - nearestBaseHitResult.HitTestPoint.Y, 2);
                    baseDistance = Math.Sqrt(baseDistance);

                    nearestHitResult.Ireplaced = distance <= DefaultHitTestRadius || baseDistance <= DefaultHitTestRadius;
                    nearestHitResult.IsVerticalHit = true;
                    nearestHitResult.DataSeriesIndex = nearestBaseHitResult.DataSeriesIndex;

                    if (RenderableSeries.DataSeries.HasMetadata)
                        nearestHitResult.Metadata = RenderableSeries.DataSeries.Metadata[nearestHitResult.DataSeriesIndex];

                    // Returning a HitTestResult with Ireplaced = true / IsVerticalHit signifies to the Rollovermodifier & TooltipModifier to show a tooltip at this location
                    return nearestHitResult;
                }
                else
                {
                    // Returning HitTestInfo.Empty signifies to the RolloverModifier & TooltipModifier there is nothing to show here
                    return HitTestInfo.Empty;
                }
            }

19 View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099

public string GetMySqlEnumSetDefine() {
		if (fsql.Ado.DataType != FreeSql.DataType.MySql) return null;
		var sb = new StringBuilder();
		foreach (var col in table.Columns) {
			if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Enum || col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set) {
				if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set) sb.Append("\r\n\t[Flags]");
				sb.Append($"\r\n\tpublic enum {this.GetCsName(this.FullTableName)}{this.GetCsName(col.Name).ToUpper()}");
				if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set) sb.Append(" : long");
				sb.Append(" {\r\n\t\t");

				string slkdgjlksdjg = "";
				int field_idx = 0;
				int unknow_idx = 0;
				string exp2 = string.Concat(col.DbTypeTextFull);
				int quote_pos = -1;
				while (true) {
					int first_pos = quote_pos = exp2.IndexOf('\'', quote_pos + 1);
					if (quote_pos == -1) break;
					while (true) {
						quote_pos = exp2.IndexOf('\'', quote_pos + 1);
						if (quote_pos == -1) break;
						int r_cout = 0;
						//for (int p = 1; true; p++) {
						//	if (exp2[quote_pos - p] == '\\') r_cout++;
						//	else break;
						//}
						while (exp2[++quote_pos] == '\'') r_cout++;
						if (r_cout % 2 == 0/* && quote_pos - first_pos > 2*/) {
							string str2 = exp2.Substring(first_pos + 1, quote_pos - first_pos - 2).Replace("''", "'");
							if (Regex.IsMatch(str2, @"^[\u0391-\uFFE5a-zA-Z_\$][\u0391-\uFFE5a-zA-Z_\$\d]*$"))
								slkdgjlksdjg += ", " + str2;
							else
								slkdgjlksdjg += string.Format(@", 
/// <summary>
/// {0}
/// </summary>
[Description(""{0}"")]
Unknow{1}", str2.Replace("\"", "\\\""), ++unknow_idx);
							if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Set)
								slkdgjlksdjg += " = " + Math.Pow(2, field_idx++);
							if (col.DbType == (int)MySql.Data.MySqlClient.MySqlDbType.Enum && field_idx++ == 0)
								slkdgjlksdjg += " = 1";
							break;
						}
					}
					if (quote_pos == -1) break;
				}
				sb.Append(slkdgjlksdjg.Substring(2).TrimStart('\r', '\n', '\t'));
				sb.Append("\r\n\t}");
			}
		}
		return sb.ToString();
	}

19 View Source File : HeatMapWithTextInCellsExampleView.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private IDataSeries CreateSeries()
        {
            const int w = 24;
            const int h = 7;

            var rnd = new Random(0);
            var data = new double[h, w];

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    data[y, x] = Math.Pow(rnd.NextDouble(), 0.15) * x / (w - 1) * y / (h - 1) * 100;
                }
            }

            return new UniformHeatmapDataSeries<int, int, double>(data, 0, 1, 0, 1);
        }

19 View Source File : AccelCalculator.cs
License : MIT License
Project Creator : a1xd

public void CalculateDirectional(AccelChartData[] dataByAngle, ManagedAccel accel, Profile settings, IReadOnlyCollection<IReadOnlyCollection<SimulatedMouseInput>> simulatedInputData)
        {
            double maxRatio = 0.0;
            double minRatio = Double.MaxValue;
            double maxSlope = 0.0;
            double minSlope = Double.MaxValue;

            int angleIndex = 0;

            foreach (var simulatedInputDataAngle in simulatedInputData)
            {
                double log = -2;
                int index = 0;
                int logIndex = 0;
                double lastInputMagnitude = 0;
                double lastOutputMagnitude = 0;

                var data = dataByAngle[angleIndex];

                foreach (var simulatedInputDatum in simulatedInputDataAngle)
                {
                    if (simulatedInputDatum.velocity <= 0)
                    {
                        continue;
                    }

                    var output = accel.Accelerate(simulatedInputDatum.x, simulatedInputDatum.y, 1, simulatedInputDatum.time);
                    var magnitude = DecimalCheck(Velocity(output.Item1, output.Item2, simulatedInputDatum.time));
                    var inDiff = Math.Round(simulatedInputDatum.velocity - lastInputMagnitude, 5);
                    var outDiff = Math.Round(magnitude - lastOutputMagnitude, 5);

                    if (inDiff == 0)
                    {
                        continue;
                    }

                    if (!data.VelocityPoints.ContainsKey(simulatedInputDatum.velocity))
                    {
                        data.VelocityPoints.Add(simulatedInputDatum.velocity, magnitude);
                    }
                    else
                    {
                        continue;
                    }

                    while (Math.Pow(10, log) < magnitude && logIndex < data.LogToIndex.Length)
                    {
                        data.LogToIndex[logIndex] = index;
                        log += 0.01;
                        logIndex++;
                    }

                    var ratio = DecimalCheck(magnitude / simulatedInputDatum.velocity);
                    var slope = DecimalCheck(inDiff > 0 ? outDiff / inDiff : settings.sensitivity);

                    bool indexToMeasureExtrema = (angleIndex == 0) || (angleIndex == (Constants.AngleDivisions - 1));
                    
                    if (angleIndex == 0 && double.IsNaN(ratio))
                    {
                        Console.WriteLine("oops");
                    }

                    if (indexToMeasureExtrema && (ratio > maxRatio))
                    {
                        maxRatio = ratio;
                    }

                    if (indexToMeasureExtrema && (ratio < minRatio))
                    {
                        minRatio = ratio;
                    }

                    if (indexToMeasureExtrema && (slope > maxSlope))
                    {
                        maxSlope = slope;
                    }

                    if (indexToMeasureExtrema && (slope < minSlope))
                    {
                        minSlope = slope;
                    }

                    if (!data.AccelPoints.ContainsKey(simulatedInputDatum.velocity))
                    {
                        data.AccelPoints.Add(simulatedInputDatum.velocity, ratio);
                    }

                    if (!data.GainPoints.ContainsKey(simulatedInputDatum.velocity))
                    {
                        data.GainPoints.Add(simulatedInputDatum.velocity, slope);
                    }

                    lastInputMagnitude = simulatedInputDatum.velocity;
                    lastOutputMagnitude = magnitude;
                    index += 1;
                }

                index--;

                while (log <= 5.0)
                {
                    data.LogToIndex[logIndex] = index;
                    log += 0.01;
                    logIndex++;
                }

                angleIndex++;
            }

            dataByAngle[0].MaxAccel = maxRatio;
            dataByAngle[0].MinAccel = minRatio;
            dataByAngle[0].MaxGain = maxSlope;
            dataByAngle[0].MinGain = minSlope;
        }

19 View Source File : ResamplingOfGridDataSeries3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            var pointsPerSlice = 65000;
            var sliceCount = 10;

            var logBase = 10;
            var slicePositions = new double[sliceCount];
            for (int i = 0; i < sliceCount; ++i)
            {
                slicePositions[i] = Math.Pow(logBase, i);
            }

            var dataSeries = new WaterfallDataSeries3D<double>(pointsPerSlice, slicePositions) { SeriesName = "Waterfall" };
            dataSeries.StartX = 10;
            dataSeries.StepX = 1;

            FillDataSeries(dataSeries, sliceCount, pointsPerSlice);

            var resampleDataSeries = ResampleDataSeries(dataSeries, slicePositions);

            WaterfallSeries.DataSeries = resampleDataSeries;
        }

19 View Source File : DataManager.cs
License : MIT License
Project Creator : ABTSoftware

public DoubleSeries GetExponentialCurve(double power, int pointCount)
        {
            var doubleSeries = new DoubleSeries(pointCount);

            double x = 0.00001;
            const double fudgeFactor = 1.4;
            for(int i = 0; i < pointCount; i++)
            {
                x *= fudgeFactor;
                double y = Math.Pow((double)i + 1, power);
                doubleSeries.Add(new XYPoint() {X = x, Y = y});
            }

            return doubleSeries;
        }

19 View Source File : OCIncident.cs
License : Apache License 2.0
Project Creator : AantCoder

public static int CalculateRaidCost(string type, long serverId, int mult, string arrivalModes, string faction)
        {
            Loger.Log("IncidentLod OCIncident.CalculateRaidCost 1");
            //var serverId = UpdateWorldController.GetServerInfo(wo).ServerId;
            var target = UpdateWorldController.GetOtherByServerId(serverId) as BaseOnline;
            if (target == null) return -1;            
            var costs = target.Player.CostWorldObjects(serverId);
            var cost = costs.MarketValue + costs.MarketValuePawn;
            if (cost <= 0) return -1;

            //{цена поселения защитника/100 000}^(2/3) * 100 * lvl ^(3/2)
            var raidCost = (int)((float)Math.Pow(cost / 100000f, 2f / 3f) * 100f 
                * (float)Math.Pow((float)mult, 3f / 2f) //* (float)mult
                * (float)SessionClientController.Data.GeneralSettings.IncidentCostPrecent / 100f
                * (type == "inf" ? 3f 
                    : type == "acid" ? 2f
                    : type == "raid" 
                    ?   (arrivalModes == "random" ? 1.5f : arrivalModes == "air" ? 1.4f : 1f)
                      * (faction == "mech" ? 5f : faction == "pirate" ? 2f : 1f)
                    : 1f)
                );

            Loger.Log($"IncidentLod OCIncident.CalculateRaidCost({serverId}, {mult}). targetCost={(int)cost} raidCost={raidCost}");

            return SessionClientController.Data.IsAdmin && Prefs.DevMode ? 1 : raidCost;
        }

19 View Source File : ChessMatch.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static double ExpectationToWin(int rank, int opRank)
        {
            var rankDiff = opRank - rank;

            return 1.0f / (1.0f + Math.Pow(10, rankDiff / 400.0f));
        }

19 View Source File : GameTest.cs
License : MIT License
Project Creator : 734843327

public Vector2d VectorDirectionNew(Vector2d start, Vector2d end){
        Vector2d result;
        double deltaX;
        double deltaY;
        deltaX = end.y - start.y;
        deltaY = end.x - start.x;
        result.x = deltaX / Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
        result.y = deltaY / Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
        return result;
      
    }

19 View Source File : ObjectDesc.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static float ScaleObj(DatLoader.Enreplacedy.ObjectDesc obj, uint x, uint y, uint k)
        {
            var scale = 1.0f;

            var minScale = obj.MinScale;
            var maxScale = obj.MaxScale;

            if (minScale == maxScale)
                scale = maxScale;
            else
                scale = (float)(Math.Pow(maxScale / minScale,
                    (1813693831 * y - (k + 32593) * (1360117743 * y * x + 1888038839) - 1109124029 * x) * 2.3283064e-10) * minScale);

            return scale;
        }

19 View Source File : EventBusRabbitMq.cs
License : MIT License
Project Creator : Abdulrhman5

public void Publish(IntegrationEvent @event)
        {
            if (!_persistentConnection.IsConnected)
            {
                _persistentConnection.TryConnect();
            }

            var policy = RetryPolicy.Handle<BrokerUnreachableException>()
                .Or<SocketException>()
                .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
                {
                    _logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s ({ExceptionMessage})", @event.Id, $"{time.TotalSeconds:n1}", ex.Message);
                });

            var eventName = @event.GetType().Name;

            _logger.LogTrace("Creating RabbitMQ channel to publish event: {EventId} ({EventName})", @event.Id, eventName);

            using (var channel = _persistentConnection.CreateModel())
            {

                _logger.LogTrace("Declaring RabbitMQ exchange to publish event: {EventId}", @event.Id);

                channel.ExchangeDeclare(exchange: BROKER_NAME, type: "direct");

                var message = JsonConvert.SerializeObject(@event);
                var body = Encoding.UTF8.GetBytes(message);

                policy.Execute(() =>
                {
                    var properties = channel.CreateBasicProperties();
                    properties.DeliveryMode = 2; // persistent

                    _logger.LogTrace("Publishing event to RabbitMQ: {EventId}, Body: {body}", @event.Id, body);

                    channel.BasicPublish(
                        exchange: BROKER_NAME,
                        routingKey: eventName,
                        mandatory: true,
                        basicProperties: properties,
                        body: body);
                });
            }
        }

19 View Source File : Creature_Missile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public float GetMaxMissileRange()
        {
            var weapon = GetEquippedMissileWeapon();
            var maxVelocity = weapon?.MaximumVelocity ?? DefaultMaxVelocity;

            var missileRange = (float)Math.Pow(maxVelocity, 2.0f) * 0.1020408163265306f;
            //var missileRange = (float)Math.Pow(maxVelocity, 2.0f) * 0.0682547266398198f;

            //var strengthMod = SkillFormula.GetAttributeMod((int)Strength.Current);
            //var maxRange = Math.Min(missileRange * strengthMod, MissileRangeCap);
            var maxRange = Math.Min(missileRange, MissileRangeCap);

            // any kind of other caps for monsters specifically?
            // throwing lugian rocks @ 85 yards seems a bit far...

            //Console.WriteLine($"{Name}.GetMaxMissileRange(): maxVelocity={maxVelocity}, strengthMod={strengthMod}, maxRange={maxRange}");

            // for client display
            /*var maxRangeYards = maxRange * MetersToYards;
            if (maxRangeYards >= 10.0f)
                maxRangeYards -= maxRangeYards % 5.0f;
            else
                maxRangeYards = (float)Math.Ceiling(maxRangeYards);

            Console.WriteLine($"Max range: {maxRange} ({maxRangeYards} yds.)");*/

            return maxRange;
        }

19 View Source File : bdsvd.cs
License : MIT License
Project Creator : 1CM69

private static bool bidiagonalsvddecompositioninternal(ref double[] d, double[] e, int n, bool isupper, bool isfractionalaccuracyrequired, ref double[,] u, int ustart, int nru, ref double[,] c, int cstart, int ncc, ref double[,] vt, int vstart, int ncvt)
  {
    int index1 = 0;
    double num1 = 0.0;
    double num2 = 0.0;
    double cs1 = 0.0;
    double sn1 = 0.0;
    double num3 = 0.0;
    double ssmin1 = 0.0;
    double ssmin2 = 0.0;
    double ssmax = 0.0;
    double num4 = 0.0;
    double num5 = 0.0;
    double sn2 = 0.0;
    double[] numArray1 = new double[0];
    double[] numArray2 = new double[0];
    double[] numArray3 = new double[0];
    double[] numArray4 = new double[0];
    double[] numArray5 = new double[0];
    double[] numArray6 = new double[0];
    double[] numArray7 = new double[0];
    double[] numArray8 = new double[0];
    double r = 0.0;
    e = (double[]) e.Clone();
    bool flag1 = true;
    if (n == 0)
      return flag1;
    if (n == 1)
    {
      if (d[1] < 0.0)
      {
        d[1] = -d[1];
        if (ncvt > 0)
        {
          for (int index2 = vstart; index2 <= vstart + ncvt - 1; ++index2)
            vt[vstart, index2] = -1.0 * vt[vstart, index2];
        }
      }
      return flag1;
    }
    double[] c1 = new double[n - 1 + 1];
    double[] s1 = new double[n - 1 + 1];
    double[] c2 = new double[n - 1 + 1];
    double[] s2 = new double[n - 1 + 1];
    int m2 = ustart + System.Math.Max(nru - 1, 0);
    int n2_1 = vstart + System.Math.Max(ncvt - 1, 0);
    int n2_2 = cstart + System.Math.Max(ncc - 1, 0);
    double[] work1 = new double[m2 + 1];
    double[] work2 = new double[n2_1 + 1];
    double[] work3 = new double[n2_2 + 1];
    int num6 = 12;
    bool isforward = true;
    double[] numArray9 = new double[n + 1];
    for (int index2 = 1; index2 <= n - 1; ++index2)
      numArray9[index2] = e[index2];
    e = new double[n + 1];
    for (int index2 = 1; index2 <= n - 1; ++index2)
      e[index2] = numArray9[index2];
    e[n] = 0.0;
    int num7 = 0;
    double num8 = 5E-16;
    double num9 = 1E-300;
    if (!isupper)
    {
      for (int index2 = 1; index2 <= n - 1; ++index2)
      {
        rotations.generaterotation(d[index2], e[index2], ref cs1, ref sn2, ref num3);
        d[index2] = num3;
        e[index2] = sn2 * d[index2 + 1];
        d[index2 + 1] = cs1 * d[index2 + 1];
        c1[index2] = cs1;
        s1[index2] = sn2;
      }
      if (nru > 0)
        rotations.applyrotationsfromtheright(isforward, ustart, m2, 1 + ustart - 1, n + ustart - 1, ref c1, ref s1, ref u, ref work1);
      if (ncc > 0)
        rotations.applyrotationsfromtheleft(isforward, 1 + cstart - 1, n + cstart - 1, cstart, n2_2, ref c1, ref s1, ref c, ref work3);
    }
    double num10 = System.Math.Max(10.0, System.Math.Min(100.0, System.Math.Pow(num8, -0.125))) * num8;
    if (!isfractionalaccuracyrequired)
      num10 = -num10;
    double val1_1 = 0.0;
    for (int index2 = 1; index2 <= n; ++index2)
      val1_1 = System.Math.Max(val1_1, System.Math.Abs(d[index2]));
    for (int index2 = 1; index2 <= n - 1; ++index2)
      val1_1 = System.Math.Max(val1_1, System.Math.Abs(e[index2]));
    double val1_2 = 0.0;
    double num11;
    if (num10 >= 0.0)
    {
      double val1_3 = System.Math.Abs(d[1]);
      if (val1_3 != 0.0)
      {
        double val2 = val1_3;
        for (int index2 = 2; index2 <= n; ++index2)
        {
          val2 = System.Math.Abs(d[index2]) * (val2 / (val2 + System.Math.Abs(e[index2 - 1])));
          val1_3 = System.Math.Min(val1_3, val2);
          if (val1_3 == 0.0)
            break;
        }
      }
      double num12 = val1_3 / System.Math.Sqrt((double) n);
      num11 = System.Math.Max(num10 * num12, (double) (num6 * n * n) * num9);
    }
    else
      num11 = System.Math.Max(System.Math.Abs(num10) * val1_1, (double) (num6 * n * n) * num9);
    int num13 = num6 * n * n;
    int num14 = 0;
    int num15 = -1;
    int num16 = -1;
    int index3 = n;
    while (index3 > 1)
    {
      if (num14 > num13)
        return false;
      if (num10 < 0.0 & System.Math.Abs(d[index3]) <= num11)
        d[index3] = 0.0;
      double val1_3 = System.Math.Abs(d[index3]);
      double val1_4 = val1_3;
      bool flag2 = false;
      for (int index2 = 1; index2 <= index3 - 1; ++index2)
      {
        index1 = index3 - index2;
        double num12 = System.Math.Abs(d[index1]);
        double val2 = System.Math.Abs(e[index1]);
        if (num10 < 0.0 & num12 <= num11)
          d[index1] = 0.0;
        if (val2 <= num11)
        {
          flag2 = true;
          break;
        }
        val1_4 = System.Math.Min(val1_4, num12);
        val1_3 = System.Math.Max(val1_3, System.Math.Max(num12, val2));
      }
      if (!flag2)
      {
        index1 = 0;
      }
      else
      {
        e[index1] = 0.0;
        if (index1 == index3 - 1)
        {
          --index3;
          continue;
        }
      }
      ++index1;
      if (index1 == index3 - 1)
      {
        bdsvd.svdv2x2(d[index3 - 1], e[index3 - 1], d[index3], ref ssmin2, ref ssmax, ref num5, ref num2, ref num4, ref num1);
        d[index3 - 1] = ssmax;
        e[index3 - 1] = 0.0;
        d[index3] = ssmin2;
        if (ncvt > 0)
        {
          int index2 = index3 + (vstart - 1);
          int index4 = index3 - 1 + (vstart - 1);
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            work2[index5] = num2 * vt[index4, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            work2[index5] = work2[index5] + num5 * vt[index2, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            vt[index2, index5] = num2 * vt[index2, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            vt[index2, index5] = vt[index2, index5] - num5 * vt[index4, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            vt[index4, index5] = work2[index5];
        }
        if (nru > 0)
        {
          int index2 = index3 + ustart - 1;
          int index4 = index3 - 1 + ustart - 1;
          for (int index5 = ustart; index5 <= m2; ++index5)
            work1[index5] = num1 * u[index5, index4];
          for (int index5 = ustart; index5 <= m2; ++index5)
            work1[index5] = work1[index5] + num4 * u[index5, index2];
          for (int index5 = ustart; index5 <= m2; ++index5)
            u[index5, index2] = num1 * u[index5, index2];
          for (int index5 = ustart; index5 <= m2; ++index5)
            u[index5, index2] = u[index5, index2] - num4 * u[index5, index4];
          for (int index5 = ustart; index5 <= m2; ++index5)
            u[index5, index4] = work1[index5];
        }
        if (ncc > 0)
        {
          int index2 = index3 + cstart - 1;
          int index4 = index3 - 1 + cstart - 1;
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            work3[index5] = num1 * c[index4, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            work3[index5] = work3[index5] + num4 * c[index2, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            c[index2, index5] = num1 * c[index2, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            c[index2, index5] = c[index2, index5] - num4 * c[index4, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            c[index4, index5] = work3[index5];
        }
        index3 -= 2;
      }
      else
      {
        bool flag3 = false;
        if (num7 == 1 & System.Math.Abs(d[index1]) < 0.001 * System.Math.Abs(d[index3]))
          flag3 = true;
        if (num7 == 2 & System.Math.Abs(d[index3]) < 0.001 * System.Math.Abs(d[index1]))
          flag3 = true;
        if (index1 != num15 | index3 != num16 | flag3)
          num7 = System.Math.Abs(d[index1]) < System.Math.Abs(d[index3]) ? 2 : 1;
        if (num7 == 1)
        {
          if (System.Math.Abs(e[index3 - 1]) <= System.Math.Abs(num10) * System.Math.Abs(d[index3]) | num10 < 0.0 & System.Math.Abs(e[index3 - 1]) <= num11)
          {
            e[index3 - 1] = 0.0;
            continue;
          }
          if (num10 >= 0.0)
          {
            double val2 = System.Math.Abs(d[index1]);
            val1_2 = val2;
            bool flag4 = false;
            for (int index2 = index1; index2 <= index3 - 1; ++index2)
            {
              if (System.Math.Abs(e[index2]) <= num10 * val2)
              {
                e[index2] = 0.0;
                flag4 = true;
                break;
              }
              val2 = System.Math.Abs(d[index2 + 1]) * (val2 / (val2 + System.Math.Abs(e[index2])));
              val1_2 = System.Math.Min(val1_2, val2);
            }
            if (flag4)
              continue;
          }
        }
        else
        {
          if (System.Math.Abs(e[index1]) <= System.Math.Abs(num10) * System.Math.Abs(d[index1]) | num10 < 0.0 & System.Math.Abs(e[index1]) <= num11)
          {
            e[index1] = 0.0;
            continue;
          }
          if (num10 >= 0.0)
          {
            double val2 = System.Math.Abs(d[index3]);
            val1_2 = val2;
            bool flag4 = false;
            for (int index2 = index3 - 1; index2 >= index1; --index2)
            {
              if (System.Math.Abs(e[index2]) <= num10 * val2)
              {
                e[index2] = 0.0;
                flag4 = true;
                break;
              }
              val2 = System.Math.Abs(d[index2]) * (val2 / (val2 + System.Math.Abs(e[index2])));
              val1_2 = System.Math.Min(val1_2, val2);
            }
            if (flag4)
              continue;
          }
        }
        num15 = index1;
        num16 = index3;
        if (num10 >= 0.0 & (double) n * num10 * (val1_2 / val1_3) <= System.Math.Max(num8, 0.01 * num10))
        {
          ssmin1 = 0.0;
        }
        else
        {
          double num12;
          if (num7 == 1)
          {
            num12 = System.Math.Abs(d[index1]);
            bdsvd.svd2x2(d[index3 - 1], e[index3 - 1], d[index3], ref ssmin1, ref num3);
          }
          else
          {
            num12 = System.Math.Abs(d[index3]);
            bdsvd.svd2x2(d[index1], e[index1], d[index1 + 1], ref ssmin1, ref num3);
          }
          if (num12 > 0.0 && AP.Math.Sqr(ssmin1 / num12) < num8)
            ssmin1 = 0.0;
        }
        num14 = num14 + index3 - index1;
        double cs2;
        if (ssmin1 == 0.0)
        {
          if (num7 == 1)
          {
            cs1 = 1.0;
            cs2 = 1.0;
            for (int index2 = index1; index2 <= index3 - 1; ++index2)
            {
              rotations.generaterotation(d[index2] * cs1, e[index2], ref cs1, ref sn2, ref num3);
              if (index2 > index1)
                e[index2 - 1] = sn1 * num3;
              rotations.generaterotation(cs2 * num3, d[index2 + 1] * sn2, ref cs2, ref sn1, ref r);
              d[index2] = r;
              c1[index2 - index1 + 1] = cs1;
              s1[index2 - index1 + 1] = sn2;
              c2[index2 - index1 + 1] = cs2;
              s2[index2 - index1 + 1] = sn1;
            }
            double num12 = d[index3] * cs1;
            d[index3] = num12 * cs2;
            e[index3 - 1] = num12 * sn1;
            if (ncvt > 0)
              rotations.applyrotationsfromtheleft(isforward, index1 + vstart - 1, index3 + vstart - 1, vstart, n2_1, ref c1, ref s1, ref vt, ref work2);
            if (nru > 0)
              rotations.applyrotationsfromtheright(isforward, ustart, m2, index1 + ustart - 1, index3 + ustart - 1, ref c2, ref s2, ref u, ref work1);
            if (ncc > 0)
              rotations.applyrotationsfromtheleft(isforward, index1 + cstart - 1, index3 + cstart - 1, cstart, n2_2, ref c2, ref s2, ref c, ref work3);
            if (System.Math.Abs(e[index3 - 1]) <= num11)
              e[index3 - 1] = 0.0;
          }
          else
          {
            cs1 = 1.0;
            cs2 = 1.0;
            for (int index2 = index3; index2 >= index1 + 1; --index2)
            {
              rotations.generaterotation(d[index2] * cs1, e[index2 - 1], ref cs1, ref sn2, ref num3);
              if (index2 < index3)
                e[index2] = sn1 * num3;
              rotations.generaterotation(cs2 * num3, d[index2 - 1] * sn2, ref cs2, ref sn1, ref r);
              d[index2] = r;
              c1[index2 - index1] = cs1;
              s1[index2 - index1] = -sn2;
              c2[index2 - index1] = cs2;
              s2[index2 - index1] = -sn1;
            }
            double num12 = d[index1] * cs1;
            d[index1] = num12 * cs2;
            e[index1] = num12 * sn1;
            if (ncvt > 0)
              rotations.applyrotationsfromtheleft(!isforward, index1 + vstart - 1, index3 + vstart - 1, vstart, n2_1, ref c2, ref s2, ref vt, ref work2);
            if (nru > 0)
              rotations.applyrotationsfromtheright(!isforward, ustart, m2, index1 + ustart - 1, index3 + ustart - 1, ref c1, ref s1, ref u, ref work1);
            if (ncc > 0)
              rotations.applyrotationsfromtheleft(!isforward, index1 + cstart - 1, index3 + cstart - 1, cstart, n2_2, ref c1, ref s1, ref c, ref work3);
            if (System.Math.Abs(e[index1]) <= num11)
              e[index1] = 0.0;
          }
        }
        else if (num7 == 1)
        {
          double f1 = (System.Math.Abs(d[index1]) - ssmin1) * (bdsvd.extsignbdsqr(1.0, d[index1]) + ssmin1 / d[index1]);
          double g = e[index1];
          for (int index2 = index1; index2 <= index3 - 1; ++index2)
          {
            rotations.generaterotation(f1, g, ref num2, ref num5, ref num3);
            if (index2 > index1)
              e[index2 - 1] = num3;
            double f2 = num2 * d[index2] + num5 * e[index2];
            e[index2] = num2 * e[index2] - num5 * d[index2];
            g = num5 * d[index2 + 1];
            d[index2 + 1] = num2 * d[index2 + 1];
            rotations.generaterotation(f2, g, ref num1, ref num4, ref num3);
            d[index2] = num3;
            f1 = num1 * e[index2] + num4 * d[index2 + 1];
            d[index2 + 1] = num1 * d[index2 + 1] - num4 * e[index2];
            if (index2 < index3 - 1)
            {
              g = num4 * e[index2 + 1];
              e[index2 + 1] = num1 * e[index2 + 1];
            }
            c1[index2 - index1 + 1] = num2;
            s1[index2 - index1 + 1] = num5;
            c2[index2 - index1 + 1] = num1;
            s2[index2 - index1 + 1] = num4;
          }
          e[index3 - 1] = f1;
          if (ncvt > 0)
            rotations.applyrotationsfromtheleft(isforward, index1 + vstart - 1, index3 + vstart - 1, vstart, n2_1, ref c1, ref s1, ref vt, ref work2);
          if (nru > 0)
            rotations.applyrotationsfromtheright(isforward, ustart, m2, index1 + ustart - 1, index3 + ustart - 1, ref c2, ref s2, ref u, ref work1);
          if (ncc > 0)
            rotations.applyrotationsfromtheleft(isforward, index1 + cstart - 1, index3 + cstart - 1, cstart, n2_2, ref c2, ref s2, ref c, ref work3);
          if (System.Math.Abs(e[index3 - 1]) <= num11)
            e[index3 - 1] = 0.0;
        }
        else
        {
          double f1 = (System.Math.Abs(d[index3]) - ssmin1) * (bdsvd.extsignbdsqr(1.0, d[index3]) + ssmin1 / d[index3]);
          double g = e[index3 - 1];
          for (int index2 = index3; index2 >= index1 + 1; --index2)
          {
            rotations.generaterotation(f1, g, ref num2, ref num5, ref num3);
            if (index2 < index3)
              e[index2] = num3;
            double f2 = num2 * d[index2] + num5 * e[index2 - 1];
            e[index2 - 1] = num2 * e[index2 - 1] - num5 * d[index2];
            g = num5 * d[index2 - 1];
            d[index2 - 1] = num2 * d[index2 - 1];
            rotations.generaterotation(f2, g, ref num1, ref num4, ref num3);
            d[index2] = num3;
            f1 = num1 * e[index2 - 1] + num4 * d[index2 - 1];
            d[index2 - 1] = num1 * d[index2 - 1] - num4 * e[index2 - 1];
            if (index2 > index1 + 1)
            {
              g = num4 * e[index2 - 2];
              e[index2 - 2] = num1 * e[index2 - 2];
            }
            c1[index2 - index1] = num2;
            s1[index2 - index1] = -num5;
            c2[index2 - index1] = num1;
            s2[index2 - index1] = -num4;
          }
          e[index1] = f1;
          if (System.Math.Abs(e[index1]) <= num11)
            e[index1] = 0.0;
          if (ncvt > 0)
            rotations.applyrotationsfromtheleft(!isforward, index1 + vstart - 1, index3 + vstart - 1, vstart, n2_1, ref c2, ref s2, ref vt, ref work2);
          if (nru > 0)
            rotations.applyrotationsfromtheright(!isforward, ustart, m2, index1 + ustart - 1, index3 + ustart - 1, ref c1, ref s1, ref u, ref work1);
          if (ncc > 0)
            rotations.applyrotationsfromtheleft(!isforward, index1 + cstart - 1, index3 + cstart - 1, cstart, n2_2, ref c1, ref s1, ref c, ref work3);
        }
      }
    }
    for (int index2 = 1; index2 <= n; ++index2)
    {
      if (d[index2] < 0.0)
      {
        d[index2] = -d[index2];
        if (ncvt > 0)
        {
          for (int index4 = vstart; index4 <= n2_1; ++index4)
            vt[index2 + vstart - 1, index4] = -1.0 * vt[index2 + vstart - 1, index4];
        }
      }
    }
    for (int index2 = 1; index2 <= n - 1; ++index2)
    {
      int index4 = 1;
      double num12 = d[1];
      for (int index5 = 2; index5 <= n + 1 - index2; ++index5)
      {
        if (d[index5] <= num12)
        {
          index4 = index5;
          num12 = d[index5];
        }
      }
      if (index4 != n + 1 - index2)
      {
        d[index4] = d[n + 1 - index2];
        d[n + 1 - index2] = num12;
        if (ncvt > 0)
        {
          int num17 = n + 1 - index2;
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            work2[index5] = vt[index4 + vstart - 1, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            vt[index4 + vstart - 1, index5] = vt[num17 + vstart - 1, index5];
          for (int index5 = vstart; index5 <= n2_1; ++index5)
            vt[num17 + vstart - 1, index5] = work2[index5];
        }
        if (nru > 0)
        {
          int num17 = n + 1 - index2;
          for (int index5 = ustart; index5 <= m2; ++index5)
            work1[index5] = u[index5, index4 + ustart - 1];
          for (int index5 = ustart; index5 <= m2; ++index5)
            u[index5, index4 + ustart - 1] = u[index5, num17 + ustart - 1];
          for (int index5 = ustart; index5 <= m2; ++index5)
            u[index5, num17 + ustart - 1] = work1[index5];
        }
        if (ncc > 0)
        {
          int num17 = n + 1 - index2;
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            work3[index5] = c[index4 + cstart - 1, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            c[index4 + cstart - 1, index5] = c[num17 + cstart - 1, index5];
          for (int index5 = cstart; index5 <= n2_2; ++index5)
            c[num17 + cstart - 1, index5] = work3[index5];
        }
      }
    }
    return flag1;
  }

19 View Source File : TippingModule.cs
License : MIT License
Project Creator : acid-chicken

[Command("rain"), Summary("条件を満たしたユーザー全員に均等に投げ銭します。端数で総金額が多少変動することがあります。末尾に`powerful`をつけると、総金額ではなく一人あたりに投げ銭される金額を指定したことになります。"), Alias("撒金"), RequireContext(ContextType.Guild | ContextType.Group)]
        public async Task RainAsync([Summary("金額")] decimal totalAmount = decimal.MinusOne, [Remainder] string comment = null)
        {
            if (totalAmount == decimal.MinusOne)
            {
                totalAmount = (decimal)Math.Pow(10, Random.NextDouble()) - 1;
            }
            var targets = await TippingManager.GetUsersAsync(Context.Channel, Context.User, 10).ConfigureAwait(false);
            if (targets.Any())
            {
                var limit = DateTimeOffset.Now.AddDays(3);
                var amount = comment?.ToLower()?.Contains("powerful") ?? false ? totalAmount : Math.Truncate(totalAmount / targets.Count * 10000000) / 10000000;
                var count = targets.Count;
                var embed =
                    new EmbedBuilder()
                        .Withreplacedle("撒き銭完了")
                        .WithDescription("撒き銭しました。DM通知は行われませんのでご注意下さい。")
                        .WithCurrentTimestamp()
                        .WithColor(Colors.Green)
                        .WithFooter(EmbedManager.CurrentFooter)
                        .WithAuthor(Context.User)
                        .AddInlineField("一人あたりの金額", $"{amount:N8} ZNY")
                        .AddInlineField("対象者数", $"{count} 人")
                        .AddInlineField("総金額", $"{amount * count:N8} ZNY");
                if (!string.IsNullOrEmpty(comment))
                {
                    embed = embed.AddField("コメント", comment);
                }
                await Task.WhenAll(targets.Select(x => TippingManager.AddRequestAsync(new TipRequest(Context.User.Id, x.Id, amount, limit))).Append(ReplyAsync
                (
                    message: Context.User.Mention,
                    embed: embed
                ))).ConfigureAwait(false);
            }
            else
            {
                await ReplyAsync
                (
                    message: Context.User.Mention,
                    embed:
                        new EmbedBuilder()
                            .Withreplacedle("撒き銭失敗")
                            .WithDescription("撒き銭に失敗しました。撒き銭対象となれるユーザーがいないか、指定した金額が不正である可能性があります。")
                            .WithCurrentTimestamp()
                            .WithColor(Colors.Red)
                            .WithFooter(EmbedManager.CurrentFooter)
                            .WithAuthor(Context.User)
                ).ConfigureAwait(false);
            }
        }

19 View Source File : BasketServiceConsoleApiClientModule.cs
License : MIT License
Project Creator : abpframework

public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            PreConfigure<AbpHttpClientBuilderOptions>(options =>
            {
                options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
                {
                    clientBuilder.AddTransientHttpErrorPolicy(
                        policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
                    );
                });
            });
        }

19 View Source File : SampleSearchScorer.cs
License : MIT License
Project Creator : Actipro

public static int Score(ProducreplacedemInfo producreplacedemInfo, string[] searchParts) {
			var score = 0;
			const int maxParts = 10;
			const int multiplierFactor = 30;

			for (var searchPartIndex = Math.Min(maxParts, searchParts.Length) - 1; searchPartIndex >= 0; searchPartIndex--) {
				var searchPart = searchParts[searchPartIndex];
				if (!string.IsNullOrEmpty(searchPart)) {
					var replacedleScore = 0;
					var replacedleIndex = producreplacedemInfo.replacedle.IndexOf(searchPart, StringComparison.OrdinalIgnoreCase);
					if (replacedleIndex >= 0)
						replacedleScore = (Math.Max(0, 30 - replacedleIndex) + 1) * (int)Math.Pow(multiplierFactor, 3);

					var categoryScore = 0;
					var categoryIndex = producreplacedemInfo.Category.IndexOf(searchPart, StringComparison.OrdinalIgnoreCase);
					if (categoryIndex >= 0)
						categoryScore = (Math.Max(0, 30 - categoryIndex) + 1) * (int)Math.Pow(multiplierFactor, 2);

					var familyreplacedleScore = 0;
					var familyreplacedleIndex = producreplacedemInfo.ProductFamily.replacedle.IndexOf(searchPart, StringComparison.OrdinalIgnoreCase);
					if (familyreplacedleIndex >= 0)
						familyreplacedleScore = (Math.Max(0, 30 - familyreplacedleIndex) + 1) * multiplierFactor;

					score += (maxParts - searchPartIndex) * (replacedleScore + categoryScore + familyreplacedleScore);
				}
			}

			return score;
		}

19 View Source File : MyUserInput.cs
License : MIT License
Project Creator : 734843327

void OnGUI()
    {
        GUI.skin.button.wordWrap = true;
        GUI.skin.button.clipping = TextClipping.Clip;
        GUI.skin.button.fontSize = 24;
        optionStyle = new GUIStyle();
        optionStyle.fontSize = 24;
        optionStyle.wordWrap = true;
        optionStyle.normal.background = optionImg;
        optionStyle.alignment = TextAnchor.MiddleCenter;
        if (null != placeInfoForGUI && placeInfoForGUI.Count > 0 && ButtonOnShow)
        {
            //var center = res.Features[0].Center;
            //_inputField.text = string.Format("{0},{1}", center.x, center.y);
            //_coordinate = res.Features[0].Center;
            for (int i = 0; i < placeInfoForGUI.Count; i++)
            {
                
                //float k = 0;
                //if (i > 2) { k = 2 * len; }
                string buttonMsg = placeInfoForGUI[i].address.ToString();

                if (GUI.Button(new Rect(Screen.width / 2 - 0.75f * len + len * (float)Math.Pow(-1, i + 1), 0.6f * (i + 1) * len, 1.5f * len, 0.6f * len), buttonMsg,optionStyle))
                {
                    MyCoordinate = placeInfoForGUI[i].coordinate;
                    ButtonDone = true;
                    GameObject.Find("GameCtrl").SendMessage("FirstFollow");
                    //Debug.Log(MyCoordinate);
                    ButtonOnShow = false;
                }
            }
            if (GUI.Button(new Rect(Screen.width * 0.386f, Screen.height * 0.927f, Screen.width * 0.57f, Screen.height * 0.05f), "\"这些都不是我想去的地方,我要重新搜索\"", GameTest.buttonStyle))
            {
                ShowInputField();
                ButtonOnShow = false;
            }


        }
        if (isResultNull && ButtonOnShow)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 1.75f, 0.6f * len, 1.5f * len, 0.6f * len), "抱歉我不知道这个地方呢,请换一个地名吧~",optionStyle))
            {
                ShowInputField();
                ButtonOnShow = false;
                isResultNull = false;
            }

        }
        if (ButtonDone && GameCtrl2.FirstFollowDone)
        {
            GameObject.Find("BaiduMapTest2").SendMessage("PreQueryDirection",MyCoordinate);//todo
            ButtonDone = false;
            //Debug.Log("ok");
        }

    }

public static double NormalDistributionValueAt(double x)
        {
            var firstTerm = (1 / Math.Sqrt(2 * Math.PI * (double)variance));
            var secondTerm = Math.Pow(Math.E, ((-1) * Math.Pow((x - (double)mean), 2)) / (2 * (double)variance));
            var result = firstTerm * secondTerm;
            return result;
        }

19 View Source File : CreateRealTime3DGeoidChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnStart()
        {
            if (!IsLoaded) return;

            int countU, countV;
            switch (DataCombo.SelectedIndex)
            {
                case 0:
                    countU = countV = 10;
                    break;
                case 1:
                    countU = countV = 50;
                    break;
                case 2:
                    countU = countV = 100;
                    break;
                case 3:
                    countU = countV = 500;
                    break;
                case 4:
                    countU = countV = 1000;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            lock (_syncRoot)
            {
                OnStop();
            }

            BitmapImage bitmapImage = new BitmapImage();

            // Load image from resources
            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnDemand;
            bitmapImage.CreateOptions = BitmapCreateOptions.DelayCreation;
            bitmapImage.DecodePixelWidth = countU;
            bitmapImage.DecodePixelHeight = countV;
            bitmapImage.UriSource = new Uri("pack://application:,,,/SciChart.Examples.ExternalDependencies;component/Resources/Images/globe_heightmap.png");
            bitmapImage.EndInit();

            // Creating Geo height (displacement) map
            var geoHeightMap = new double[countU, countV];
            int nStride = (bitmapImage.PixelWidth * bitmapImage.Format.BitsPerPixel + 7) / 8;
            int bytsPerPixel = bitmapImage.Format.BitsPerPixel / 8;
            byte[] pixelByteArray = new byte[bitmapImage.PixelWidth * nStride];
            bitmapImage.CopyPixels(pixelByteArray, nStride, 0);
            for (int v = 0; v < countV; v++)
            {
                for (var u = 0; u < countU; u++)
                {
                    int pixelIndex = v * nStride + u * bytsPerPixel;
                    var offset = pixelByteArray[pixelIndex] / 255.0f;
                    geoHeightMap[v, u] = offset;
                }
            }

            var dataSeries = new EllipsoidDataSeries3D<double>(countU, countV)
            {
                SeriesName = "Geo Mesh",
                A = 6,
                B = 6,
                C = 6
            };

            var frontBuffer = dataSeries.InternalArray;
            var backBuffer = new GridData<double>(countU, countV).InternalArray;

            int frames = 0;
            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(20);
            _timer.Tick += (s, arg) =>
            {
                lock (_syncRoot)
                {
                    double heightOffsetsScale = sliderHeightOffsetsScale.Value;
                    double freq = (Math.Sin(frames++*0.1) + 1.0) / 2.0;

                    // Each set of geoHeightMap[i,j] schedules a redraw when the next Render event fires. Therefore, we suspend updates so that we can update the chart once
                    // We parallelize it by using Parallel.For for the outer loop
                    //  Equivalent of "for (int j = 0; j < countU; j++)"
                    // This will result in more CPU usage, but we wish to demo the performance of the actual rendering, not the slowness of generating test data! :)
                    Parallel.For(0, countV, i =>
                    {
                        var buf = frontBuffer;
                        for (int j = 0; j < countU; j++)
                        {
                            // Rotate (offset) J index
                            int rj = j + frames;
                            if (rj >= countU)
                            {
                                rj -= countU * (rj / countU);
                            }

                            buf[i][j] = geoHeightMap[i, rj] + Math.Pow(geoHeightMap[i, rj], freq * 10.0) * heightOffsetsScale;
                        }
                    });

                    using (dataSeries.SuspendUpdates(false, true))
                    {
                        dataSeries.CopyFrom(frontBuffer);
                        var temp = backBuffer;
                        backBuffer = frontBuffer;
                        frontBuffer = temp;
                    }
                }
            };
            SurfaceMesh.DataSeries = dataSeries;
            _timer.Start();
            StartButton.IsEnabled = false;
            PauseButton.IsEnabled = true;
        }

public void replacedignCS(double a, double b)
        {
            r = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2));
            c = (a / r);
            s = -1 * (b / r);
            s_0 = (b / r);
        }

19 View Source File : ZColorPicker.cs
License : MIT License
Project Creator : 0xLaileb

private Color GetPixelColor(float x, float y, float value, float radius)
        {
            float R = (float)Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
            float S = (float)(R / radius);
            if (S > 1) return Color.Transparent;

            double Angle;
            if (x > 0 && y > 0) Angle = Math.Asin(y / R);
            else if (x <= 0 && y > 0) Angle = Math.Acos(y / R) + Math.PI / 2;
            else if (x <= 0 && y <= 0) Angle = Math.Asin(-y / R) + Math.PI;
            else Angle = Math.Acos(-y / R) + 3 * Math.PI / 2;
            float H = (float)(Angle / Math.PI / 2);

            return HSVtoRGB(H, S, value);
        }

19 View Source File : nThDifferential.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence

public IList<decimal> DifferentialRow(int n, decimal constant, double h)
        {
            var row = new List<decimal>();
            var cnt = 0;
            for (int i = n; i > 0; i--)
            {
                row.Add((constant * (n - (cnt - 1)) * (decimal)Math.Pow((-1), (cnt))) / ((decimal)Math.Pow(h, 2 * n)));
                cnt++;
            }
            return row;
        }

19 View Source File : CreateAWaterfall3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            var pointsPerSlice = 100;
            var sliceCount = 20;

            var logBase = 10;
            var slicePositions = new double[sliceCount];

            for (int i = 0; i < sliceCount; ++i)
            {
                slicePositions[i] = Math.Pow(logBase, i);
            }

            var dataSeries = new WaterfallDataSeries3D<double>(pointsPerSlice, slicePositions)
            {
                SeriesName = "Waterfall",
                StartX = 10,
                StepX = 1
            };

            _transform.init((uint)Math.Log(pointsPerSlice, 2));

            FillDataSeries(dataSeries, sliceCount, pointsPerSlice);
            WaterfallSeries.DataSeries = dataSeries;
        }

19 View Source File : GameExtension.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826

public static string ToKunFuLevel(this int exp,int playerExp)
        {
            if (playerExp - exp * 1.5 <= 0)
            {
                return "的武功看不出深浅。";
            }

            var level = (int)Math.Round(Math.Pow(exp, 0.236) / 1.5, MidpointRounding.AwayFromZero);
            var levels = new[] { "不堪一击", "毫不足虑", "不足挂齿", "初学乍练", "勉勉强强", "初窥门径", "初出茅庐", "略知一二", "普普通通", "平平淡淡", "平淡无奇", "粗通皮毛", "半生不熟", "马马虎虎", "略有小成", "已有小成", "鹤立鸡群", "驾轻就熟", "青出于蓝", "融会贯通", "心领神会", "炉火纯青", "了然于胸", "略有大成", "已有大成", "豁然贯通", "出类拔萃", "无可匹敌", "技冠群雄", "神乎其技", "出神入化", "非同凡响", "傲视群雄", "登峰造极", "无与伦比", "所向披靡", "一代宗师", "精深奥妙", "神功盖世", "举世无双", "惊世骇俗", "撼天动地", "震古铄今", "超凡入圣", "威镇寰宇", "空前绝后", "天人合一", "深藏不露", "深不可测" };

            string description;
            if (level <= 0)
            {
                description = "不堪一击";
            }
            else if (level >= levels.Length)
            {
                description = "深不可测";
            }
            else
            {
                description = levels[level - 1];
            }

            return $"的武功看上去{description}。";
        }

19 View Source File : ZColorPicker.cs
License : MIT License
Project Creator : 0xLaileb

private Color PickColor(float x, float y)
        {
            float x1 = x - (float)pictureBox1.Width / 2;
            float y1 = y - (float)pictureBox1.Height / 2;
            float Radius = (float)Math.Sqrt(Math.Pow(x1, 2) + Math.Pow(y1, 2));
            if (Radius > (float)pictureBox1.Width / 2)
            {
                float mult = (float)pictureBox1.Width / 2 / Radius;
                x1 *= mult;
                y1 *= mult;
            }
            Color Color = GetPixelColor(x1, y1, ((ValueBox)pictureBox3.Tag).Value, (float)pictureBox1.Width / 2);
            if (Color == Color.Transparent) return Color.Empty;

            label1.Text = $"RGB: {Color.R}, {Color.G}, {Color.B}";
            label2.Text = $"HEX: #{Color.ToArgb():X}";
            CursorPos = new PointF(x1 + (float)pictureBox1.Width / 2, y1 + (float)pictureBox1.Height / 2);
            pictureBox2.BackColor = Color;
            ((ValueBox)pictureBox3.Tag).Color = Color;
            pictureBox1.Tag = new PointF(x, y);
            pictureBox1.Invalidate();
            pictureBox2.Invalidate();
            pictureBox3.Invalidate();

            SelectedColor = Color;
            return Color;
        }

19 View Source File : LSQcalculator.cs
License : MIT License
Project Creator : 1CM69

private void calculatebasefuncs(ref double[,] basefunctions, ref float[] x, int funcs, int numpoints)
    {
      for (int index1 = 0; index1 < numpoints; ++index1)
      {
        for (int index2 = 0; index2 < funcs; ++index2)
          basefunctions[index1, index2] = Math.Pow((double) x[index1], (double) (funcs - 1 - index2));
      }
    }

19 View Source File : GlobalFunctions.cs
License : MIT License
Project Creator : 3RD-Dimension

public static string DecimalPlaceNoRounding(double d, int decimalPlaces)
        {
            d = d * Math.Pow(10, decimalPlaces);
            d = Math.Truncate(d);
            d = d / Math.Pow(10, decimalPlaces);
            return string.Format("{0:N" + Math.Abs(decimalPlaces) + "}", d);
        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

void WriteStatus(string replacedle, Dictionary<string, Dictionary<int, long>> timings)
        {
            WriteLine(replacedle, ConsoleColor.Yellow);
            foreach (var item in timings)
            {
                double mean = item.Value.Values.Average();
                double variance = 0;

                Write(item.Key + "\t\t");
                foreach (var it in item.Value)
                {
                    Write(it.Value + "\t");
                    variance += Math.Pow((it.Value - mean), 2);
                }
                variance = variance / item.Value.Values.Count;

                Write(item.Value.Values.Average() + "\t");
                Write(Math.Sqrt(variance) + "\t");

                WriteLine("");
            }
        }

19 View Source File : DataManager.cs
License : MIT License
Project Creator : ABTSoftware

public DoubleSeries GetButterflyCurve(int count=2000)
        {
            // From http://en.wikipedia.org/wiki/Butterfly_curve_%28transcendental%29
            // x = sin(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12)) 
            // y = cos(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12))
            var temp = 0.01;
            var doubleSeries = new DoubleSeries(count);
            for (int i = 0; i < count; i++)
            {
                var t = i*temp;

                double multiplier = Math.Pow(Math.E, Math.Cos(t)) - 2*Math.Cos(4*t) - Math.Pow(Math.Sin(t/12), 5);

                double x = Math.Sin(t)*multiplier;
                double y = Math.Cos(t) * multiplier;
                doubleSeries.Add(new XYPoint {X = x, Y = y});
            }
            return doubleSeries;
        }

See More Examples