示例#1
0
 /// <summary>
 /// To the polar.
 /// </summary>
 /// <returns>PolarCoordinate.</returns>
 public PolarCoordinate ToPolar()
 {
     return(new PolarCoordinate(
                radius: Algebra.SRSS(X, Y),
                rotation: new Angle(NMath.Atan(Y / X))
                ));
 }
示例#2
0
    public static int Math_ATan(ILuaState luaState)
    {
        double rad = luaState.ToNumber(-1) * Mathf.Deg2Rad;

        luaState.PushNumber((float)Math.Atan(rad));
        return(1);
    }
示例#3
0
        static SinCosTable()
        {
            var ct  = new T[256];
            var att = new T[256];

            for (int i = 0; i < ct.Length; i++)
            {
                ct[i]  = M.Cos(invCosTableFactor * i);
                att[i] = M.Atan(invAtanTableFactor * i);
            }
            _cosTable  = ct;
            _atanTable = att;
        }
 public static double Atan(double d)
 => Math.Atan(d);
示例#5
0
 public static Half Atan(Half x) =>
 (Half)M.Atan(x);
示例#6
0
文件: Math.cs 项目: zjloscar/Dynamo
 public static double Atan(double value)
 {
     return(CSMath.Atan(value) * kRadiansToDegrees);
 }
示例#7
0
 public static Angle Atan(Real radians)
 {
     return(FromRadians(Math.Atan(radians)));
 }
示例#8
0
 /// <summary>
 ///     Finds the inverse tangent, the angle whose tangent is the given ratio.
 /// </summary>
 /// <param name="ratio">The tangent of the angle.</param>
 /// <returns name="angle">The angle whose tangent is the input ratio.</returns>
 /// <search>atangent,arctangent</search>
 public static double Atan(double ratio)
 {
     return(CSMath.Atan(ratio) * kRadiansToDegrees);
 }
示例#9
0
 // Inverse Cotangent
 public static double Arccotan(double x)
 {
     return(2 * MathObj.Atan(1) - MathObj.Atan(x));
 }
示例#10
0
 // Inverse Cosecant
 public static double Arccosec(double x)
 {
     return(MathObj.Atan(MathObj.Sign(x) / MathObj.Sqrt(x * x - 1)));
 }
示例#11
0
 // Inverse Cosine
 public static double Arccos(double x)
 {
     return(MathObj.Atan(-x / MathObj.Sqrt(-x * x + 1)) + 2 * MathObj.Atan(1));
 }
示例#12
0
 // Inverse Sine
 public static double Arcsin(double x)
 {
     return(MathObj.Atan(x / MathObj.Sqrt(-x * x + 1)));
 }
示例#13
0
        private static void SpawnCursor()
        {
            var cur_size = 128;

            var pi = Math.Atan(1) * 4;

            var frames = 24;

            var a =
                from i in
                (from j in Enumerable.Range(0, (frames / 2) - 0) select j / frames * pi)
                //let x = Math.Cos(i)
                //let y = Math.Sin(i)
                select new XPosition {
                x = Math.Cos(i), y = Math.Sin(i)
            };

            //a.ForEach(z => Console.WriteLine(z.ToString()));

            var moon_frames = frames * 1.3;
            var moon_range  = (int)Math.Floor((moon_frames * 0.33));
            var moon_max    = (0 - (moon_range / 2)) / moon_frames * pi;

            var dualmoon =
                (from offset in
                 (from j in Enumerable.Range(0, moon_range) select(j - (moon_range / 2)) / moon_frames * pi)
                 select new XDualMoon
            {
                offset = offset,
                moon1 = new SpecialLayer(),
                moon2 = new SpecialLayer()
            }).ToArray();


            dualmoon.ForEach(
                dual =>
            {
                double op = 1 - (Math.Abs((double)(dual.offset / moon_max)));

                int size = (int)Math.Floor(4 * (op + 1));

                dual.moon1.div.style.Opacity = 0.6;
                dual.moon2.div.style.Opacity = 0.6;

                dual.moon1.x = size;
                dual.moon1.y = size;

                dual.moon2.x = size;
                dual.moon2.y = size;


                dual.moon1.div.style.Opacity = op;
                dual.moon2.div.style.Opacity = op;

                dual.moon1.div.className = "moon1";
                dual.moon2.div.className = "moon1";


                dual.moon1.div.AttachToDocument();
            }
                );

            var b = a.Select(
                i =>
            {
                var layer = new SpecialLayer {
                    x = (int)System.Math.Floor(i.x * cur_size), y = (int)System.Math.Floor(i.y * cur_size)
                };

                layer.div.style.Opacity = 0.4;
                layer.div.className     = "effect1";
                layer.div.AttachToDocument();

                return(layer);
            }
                ).ToArray();


            var p = new Point(0, 0);


            dualmoon.ForEach(
                dual =>
            {
                dual.moon2.div.AttachToDocument();
            }
                );


            System.Action moon_update =
                () =>
            {
                var seed = IDate.Now.getTime() / 1000;


                dualmoon.ForEach(
                    dual =>
                {
                    double rad = seed + dual.offset;

                    var deg = (rad + pi / 2) % (2 * pi);

                    if (deg > pi)
                    {
                        deg = (2 * pi) - deg;
                    }

                    deg /= pi;

                    if (deg > 0.5)
                    {
                        dual.moon1.div.style.visibility = IStyle.VisibilityEnum.hidden;
                        dual.moon2.div.style.visibility = IStyle.VisibilityEnum.visible;
                    }
                    else
                    {
                        dual.moon1.div.style.visibility = IStyle.VisibilityEnum.visible;
                        dual.moon2.div.style.visibility = IStyle.VisibilityEnum.hidden;
                    }


                    new[] { dual.moon1 }.Concat(new[] { dual.moon2 }).ForEach(
                        moon =>
                    {
                        var cos = Math.Cos(rad) * cur_size;

                        moon.SetCenteredLocation(
                            (int)Math.Floor(p.X + cos),
                            (int)Math.Floor(p.Y + -cos * 0.6)
                            );



                        moon.zoom = 1 + deg;

                        moon.UpdateSize();
                    }
                        );
                });
            };

            Native.Document.onmousemove +=
                delegate(IEvent ev)
            {
                p = ev.CursorPosition;

                b.ForEach(
                    layer =>
                {
                    layer.SetCenteredLocation(p.X, p.Y);
                    layer.UpdateSize();
                }
                    );

                moon_update();
            };



            new Timer(
                t =>
            {
                moon_update();
            }
                , 1, 150);
        }
示例#14
0
 public static double Atan(double d)
 {
     return(Math.Atan(d));
 }
        private void GetRealAndImagValues(double freq, out double realVal, out double imagVal, int chargeState)
        {
            double r     = 1;
            double theta = 0;



            foreach (var element in _elementTable)
            {
                var numAtoms = element.Value;

                var elementObject = _elementList[element.Key];


                var numIsotopes = elementObject.IsotopeDictionary.Count;

                var averageMass = elementObject.MassAverage;

                double real = 0;
                double imag = 0;


                var isotopes = elementObject.IsotopeDictionary.Values;

                foreach (var isotope in isotopes)
                {
                    double wrapFrequency = 0;
                    if (numIsotopes > 1)
                    {
                        wrapFrequency = isotope.Mass / chargeState - averageMass / chargeState;
                        if (wrapFrequency < 0)
                        {
                            wrapFrequency += _massRange;
                        }
                    }

                    var x = 2 * Math.PI * wrapFrequency * freq;

                    real += isotope.NaturalAbundance * Math.Cos(x);
                    imag += isotope.NaturalAbundance * Math.Sin(x);
                }

                var tempR = Math.Sqrt(real * real + imag * imag);
                r *= Math.Pow(tempR, numAtoms);

                if (real > 0)
                {
                    theta += numAtoms * Math.Atan(imag / real);
                }
                else if (real < 0)
                {
                    theta += numAtoms * (Math.Atan(imag / real) + Math.PI);
                }
                else if (imag > 0)
                {
                    theta += numAtoms * Math.PI / 2;
                }
                else
                {
                    theta += numAtoms * -Math.PI / 2;
                }
            }

            realVal = r * Math.Cos(theta);
            imagVal = r * Math.Sin(theta);
        }
示例#16
0
 /// <summary>
 /// Returns the angle [radians] of a vector from the origin axis (x, positive, +ccw).
 /// </summary>
 /// <returns></returns>
 public double Angle()
 {
     return(NMath.Atan(_vector.Y / _vector.X));
 }