Esempio n. 1
0
    public static FixedPoint operator *(FixedPoint a, long b)
    {
        FixedPoint result = new FixedPoint();

        result.value = a.value * b;
        return(result);
    }
Esempio n. 2
0
    public static FixedPoint operator -(FixedPoint a, FixedPoint b)
    {
        FixedPoint result = new FixedPoint();

        result.value = a.value - b.value;
        return(result);
    }
Esempio n. 3
0
    public static FixedPoint operator /(FixedPoint a, int b)
    {
        FixedPoint result = new FixedPoint();

        result.value = a.value / b;
        return(result);
    }
Esempio n. 4
0
    public static FixedPoint operator *(FixedPoint a, FixedPoint b)
    {
        FixedPoint result = new FixedPoint();

        result.value = (a.value * b.value) / fixedPoint;
        return(result);
    }
Esempio n. 5
0
 public void UpdateBehavior(FixedPoint dt)
 {
     foreach (var e in gameController.entities)
     {
         e.behavior.UpdateLogics(dt, gameController);
     }
 }
Esempio n. 6
0
        public CollisionProcessor(int _gridSize,
                                  FixedPoint w, FixedPoint h, FixedPoint bounds,
                                  BehaviorController bc)
        {
            gridSize = _gridSize;

            sceneWidth  = w;
            sceneHeight = h;

            boundarySize = bounds;

            gridCellWidth  = w / (FixedPoint)_gridSize;
            gridCellHeight = h / (FixedPoint)_gridSize;

            colliderGrid = new Body[gridSize][][];

            for (int i = 0; i < _gridSize; i++)
            {
                colliderGrid[i] = new Body[gridSize][];

                for (int j = 0; j < _gridSize; j++)
                {
                    colliderGrid[i][j] = new Body[gridCapacity];
                }
            }

            behaviorController = bc;
        }
Esempio n. 7
0
    public static FixedPoint operator /(FixedPoint a, FixedPoint b)
    {
        FixedPoint result = new FixedPoint();

        result.value = (a.value * fixedPoint) / b.value;
        return(result);
    }
Esempio n. 8
0
 public OrientedBoxBody(FixedPointVector3 pos, FixedPoint w, FixedPoint h, FixedPoint a, Entity _owner) : base(pos)
 {
     angle  = a;
     width  = w;
     height = h;
     owner  = _owner;
 }
Esempio n. 9
0
        public void CanIntersect(string ptsStr, int?x, int?y, bool expected)
        {
            if (x.HasValue && y.HasValue)
            {
                throw new Exception();
            }
            if (!x.HasValue && !y.HasValue)
            {
                throw new Exception();
            }

            var poly = _ParsePattern(ptsStr);

            bool val;

            if (x.HasValue)
            {
                val = poly.CanDivideAlongVertical(FixedPoint.FromInt(x.Value));
            }
            else
            {
                val = poly.CanDivideAlongHorizontal(FixedPoint.FromInt(y.Value));
            }

            Assert.Equal(expected, val);
        }
Esempio n. 10
0
        public void ValueFloatByteFailureTest()
        {
            Should.Throw <ArgumentOutOfRangeException>(() => float.NaN.MakeFixedPoint <byte>(5, 4));
            Should.Throw <ArgumentOutOfRangeException>(() => float.NaN.MakeFixedPoint <byte>(0, 0));

            Should.Throw <ArgumentOutOfRangeException>(() => FixedPoint.MakeFloat <byte>(0x0f, 5, 4));
            Should.Throw <ArgumentOutOfRangeException>(() => ((byte)0x0f).MakeFloat(0, 0));

            Should.Throw <OverflowException>(() => 18f.MakeFixedPoint <byte>(4, 0));

            Should.Throw <OverflowException>(() => (-1f).MakeFixedPoint <byte>(4, 0));

            Should.Throw <OverflowException>(() => ((float)FixedPoint.SmallestWholeValue(4, allowNegative: true) - 1).MakeFixedPoint <Int16>(4, 0));

            Should.Throw <OverflowException>(() => double.MaxValue.MakeFixedPoint <UInt64>(63, 0));
            Should.Throw <OverflowException>(() => float.MaxValue.MakeFixedPoint <UInt64>(63, 0));

            // From a raw numbers perspective this should not throw, but the real value is getting rounded when being
            // converted to a UInt64 because of loss of precision which is causing the conversion to overflow.
            //
            Should.Throw <OverflowException>(() => 9.2233720368547758E+18.MakeFixedPoint <UInt64>(63, 0).ShouldBe(0x7FFFFFFFFFFFFFFFul));

            Should.Throw <ArgumentOutOfRangeException>(() => FixedPoint.LargestWholeValue(100, allowNegative: true));

            Should.Throw <ArgumentOutOfRangeException>(() => FixedPoint.SmallestWholeValue(100, allowNegative: true));

            Should.Throw <ArgumentOutOfRangeException>(() => 10f.MakeFixedPoint <int>(100, fractionalBits: 0));

            FixedPoint.SmallestWholeValue(10, allowNegative: false).ShouldBe(0);
            FixedPoint.SmallestWholeValue(0, allowNegative: true).ShouldBe(0);

            Should.Throw <TypeInitializationException>(() => 2f.MakeFixedPoint <float>(4, 0)).InnerException.ShouldBeOfType <ArgumentException>();
        }
Esempio n. 11
0
        public IGameLoop SetPhysicsSimulationsPerSecond(uint frequency)
        {
            _physicsSimulationsPerSecond = TicksPerSecond / frequency;
            _physicsDeltaPerSimulation   = FixedPoint.From(frequency);

            return(this);
        }
Esempio n. 12
0
        public void SplitVertically(string ptsStr, int x, string leftPtsExpected, string rightPtsExpected)
        {
            var poly = _ParsePattern(ptsStr);

            var split = poly.SplitVertically(FixedPoint.FromInt(x), ScratchPoints1, ScratchPoints2, ScratchPoints3);
            var left  = split[0];
            var right = split[1];

            var pts = new List <string>();

            foreach (var pt in left.Vertices)
            {
                pts.Add("(" + pt.X + "," + pt.Y + ")");
            }
            var leftPts = string.Join(";", pts);

            pts.Clear();
            foreach (var pt in right.Vertices)
            {
                pts.Add("(" + pt.X + "," + pt.Y + ")");
            }
            var rightPts = string.Join(";", pts);

            Assert.Equal(leftPtsExpected, leftPts);
            Assert.Equal(rightPtsExpected, rightPts);
        }
Esempio n. 13
0
        public void SplitHorizontally(string ptsStr, int y, string topPtsExpected, string bottomPtsExpected)
        {
            var poly = _ParsePattern(ptsStr);

            var split  = poly.SplitHorizontally(FixedPoint.FromInt(y), ScratchPoints1, ScratchPoints2, ScratchPoints3);
            var top    = split[0];
            var bottom = split[1];

            var pts = new List <string>();

            foreach (var pt in top.Vertices)
            {
                pts.Add("(" + pt.X + "," + pt.Y + ")");
            }
            var topPts = string.Join(";", pts);

            pts.Clear();
            foreach (var pt in bottom.Vertices)
            {
                pts.Add("(" + pt.X + "," + pt.Y + ")");
            }
            var bottomPts = string.Join(";", pts);

            Assert.Equal(topPtsExpected, topPts);
            Assert.Equal(bottomPtsExpected, bottomPts);
        }
Esempio n. 14
0
 public static FixedPoint GetAngleBetweenVectors(FixedPointVector2 v1, FixedPointVector2 v2)
 {
     return(FixedPoint.Atan2(
                v1.X * v2.Y - v2.X * v1.Y,
                v1.X * v2.X + v1.Y * v2.Y
                ));
 }
Esempio n. 15
0
File: Entities.cs Progetto: N-01/UFO
    public Ufo(FixedPointVector3 _pos, FixedPoint _diameter)
    {
        type = EntityType.Ufo;

        originPosition          = _pos;
        speed                   = Extensions.Range(0.5f, 1f);
        orbitRadius             = scale;
        asteroidDetectionRadius = _diameter * 5;

        health = 20;

        body = new CircleBody(originPosition, _diameter * (FixedPoint)0.5f, this);

        body.SetLayer(type);
        body.SetCollidesWith(EntityType.Asteroid, true);
        body.SetCollidesWith(EntityType.Blast, true);
        body.SetCollidesWith(EntityType.Placeholder, true);
        body.SetCollidesWith(EntityType.Ufo, true);

        //randomize rotations
        if (Random.value > 0.5f)
        {
            orbitSpeedPerSecond = -orbitSpeedPerSecond;
        }

        currentOrbitAngle = Extensions.Range(0, Mathf.PI * 2);

        behavior = new UfoBehavior(this);
    }
Esempio n. 16
0
        public Dictionary <FixedPoint, FixedPoint> CalculateSqrtData()
        {
            var data = GetTableDto(Operation.Sqrt);

            return(data.ToDictionary(x => FixedPoint.FromExplicit(x.Key), x => FixedPoint.FromExplicit(x.Value)
                                     , FixedPointEqualityComparer.Instance));
        }
Esempio n. 17
0
        public static FixedPointVector3 operator -(FixedPointVector3 a, FixedPointVector3 b)
        {
            FixedPoint x = a.X - b.X;
            FixedPoint y = a.Y - b.Y;
            FixedPoint z = a.Z - b.Z;

            return(new FixedPointVector3(x, y, z));
        }
Esempio n. 18
0
        public static FixedPointVector3 operator /(FixedPointVector3 a, FixedPoint b)
        {
            FixedPoint x = a.X / b;
            FixedPoint y = a.Y / b;
            FixedPoint z = a.Z / b;

            return(new FixedPointVector3(x, y, z));
        }
Esempio n. 19
0
File: Mathfp.cs Progetto: N-01/UFO
 public static FixedPoint Abs(FixedPoint value)
 {
     if (value < (FixedPoint)0)
     {
         return(value * (FixedPoint)(-1));
     }
     return(value);
 }
Esempio n. 20
0
        public RigidBodyWithColliderBuilder SetCircleCollider(FixedPoint radius, FixedPointVector2?centre = null)
        {
            _circleColliderRadius = radius;
            _circleColliderCentre = centre ?? FixedPointVector2.Zero;
            _colliderType         = ColliderType.Circle;

            return(this);
        }
Esempio n. 21
0
 public static FixedPointVector2 Truncate(FixedPointVector2 v, FixedPoint length)
 {
     if (v.GetLengthSquared() > length * length)
     {
         v = v.Normalize() * length;
     }
     return(v);
 }
Esempio n. 22
0
 public static FixedPoint DistanceSquared(FixedPointVector2 v1, FixedPointVector2 v2)
 {
     unchecked {
         FixedPoint x = v1.X - v2.X;
         FixedPoint y = v1.Y - v2.Y;
         return(x * x + y * y);
     }
 }
Esempio n. 23
0
        private void btnAddMarker_Click(object sender, EventArgs e)
        {
            string name = txtNumber.Text;
            PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text);
            foreach (Control c in Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text == "")
                    {
                        if (c != txtRemark)
                        {
                            MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                    }
                }
            }
            if (editMode == true)
            {
                main.detailMarkers.Remove(getmarker);
                main.markerOverlay.Markers.Remove(getmarker);
                main.markerOverlay.Markers.Remove(getrect);
                AutoIncrementID -= 1;
                Image image = Image.FromFile("Images/icon/FIxedPoint.png");
                GMarker marker = new GMarker(point, name, image);
                GMarkerRect rect = new GMarkerRect(marker);

                //Add Data to dictionary
                FixedPoint fixedPoint = new FixedPoint("FP" + "0" + (AutoIncrementID += 1).ToString(), txtNumber.Text, checkType, txtLabel.Text, checkSIM, txtRemark.Text, point);
                main.detailMarkers.Add(marker, fixedPoint);

                // TODO : Manage data before adding to overlay
                main.markerOverlay.Markers.Add(marker);
                main.markerOverlay.Markers.Add(rect);
                this.seteditMode(false);
                MessageBox.Show("แก้ไขสำเร็จ");
                clearField();
            }
            else
            {
                // TODO : Selecting image to display as marker
                Image image = Image.FromFile("Images/icon/FIxedPoint.png");
                GMarker marker = new GMarker(point, name, image);
                GMarkerRect rect = new GMarkerRect(marker);

                //Add Data to dictionary
                FixedPoint fixedPoint = new FixedPoint("FP" + "0" + (AutoIncrementID += 1).ToString(), txtNumber.Text, checkType, txtLabel.Text, checkSIM, txtRemark.Text, point);
                main.detailMarkers.Add(marker, fixedPoint);

                // TODO : Manage data before adding to overlay
                main.markerOverlay.Markers.Add(marker);
                main.markerOverlay.Markers.Add(rect);
                MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "FixedPoint Marker");
                clearField();
            }
        }
Esempio n. 24
0
        public FixedPointVector2 Rotate(FixedPoint angle)
        {
            unchecked {
                FixedPoint cos = angle.Cos();
                FixedPoint sin = angle.Sin();

                return(new FixedPointVector2(X * cos - Y * sin, X * sin + Y * cos));
            }
        }
Esempio n. 25
0
 public static FixedPoint Distance(FixedPointVector2 v1, FixedPointVector2 v2)
 {
     unchecked {
         FixedPoint x = v1.X - v2.X;
         FixedPoint y = v1.Y - v2.Y;
         FixedPoint f = x * x + y * y;
         return(f.Sqrt());
     }
 }
Esempio n. 26
0
 void Start()
 {
     for (int i = 0; i < fixedPoints.Count; i++)
     {
         FixedPoint start = fixedPoints[i];
         FixedPoint end;
         if (i + 1 == fixedPoints.Count)
         {
             end = fixedPoints[0];
         }
         else
         {
             end = fixedPoints[i + 1];
         }
         Vector2 startNormal     = Quaternion.AngleAxis(90, Vector3.back) * (start.handle - start.location);
         Vector2 diff            = end.location - start.location;
         float   dist            = diff.magnitude;
         Vector2 circleDirection = Vector3.Project(diff, startNormal).normalized;
         float   travelDist;
         float   totalAngle = 0;
         if (circleDirection.SqrMagnitude() == 0)
         {
             travelDist = Vector3.Distance(start.location, end.location);
         }
         else
         {
             float   centerAngle  = Vector2.SignedAngle(circleDirection, diff);
             float   r            = (dist / 2) / Mathf.Cos(Mathf.Deg2Rad * centerAngle);
             Vector2 circleCenter = start.location + circleDirection * r;
             // Debug.DrawLine(start.location, circleCenter, Color.blue, 1000000);
             // Debug.DrawLine(start.location, start.location + circleDirection, Color.yellow, 1000000);
             // Debug.DrawLine(start.location, start.location + startNormal, Color.green, 1000000);
             // Debug.DrawLine(start.location, start.location + diff, Color.red, 1000000);
             // for (int a = 0; a < 360; a++)
             // {
             //     Debug.DrawLine((Vector3)circleCenter + Quaternion.AngleAxis(a, Vector3.back) * Vector2.left * r, (Vector3)circleCenter + Quaternion.AngleAxis(a - 1, Vector3.back) * Vector2.left * r, Color.cyan, 10000000);
             // }
             totalAngle = GetAngle(-circleDirection, end.location - circleCenter, Vector2.Dot(circleDirection, startNormal) < 0);
             travelDist = r * 3.1415f * 2 * Mathf.Abs(totalAngle) / 360;
         }
         int     dots       = (int)(travelDist * 5);
         float   step       = travelDist / dots;
         float   aStep      = totalAngle / dots;
         Vector2 currentDir = (start.handle - start.location).normalized;
         Vector2 basePos    = start.location;
         for (int n = 0; n < dots; n++)
         {
             points.Add(basePos);
             basePos   += currentDir * step;
             currentDir = Quaternion.AngleAxis(aStep, Vector3.back) * currentDir;
         }
     }
     pointsHome = new List <Vector2>(points);
     GetComponent <PolygonCollider2D>().points   = points.ToArray();
     GetComponent <LineRenderer>().positionCount = points.Count;
     GetComponent <LineRenderer>().SetPositions(To3D(points.ToArray()));
 }
Esempio n. 27
0
File: Mathfp.cs Progetto: N-01/UFO
        public static FixedPoint LowerClamp(FixedPoint value, FixedPoint lowerLimit)
        {
            if (value < lowerLimit)
            {
                return(lowerLimit);
            }

            return(value);
        }
Esempio n. 28
0
File: Mathfp.cs Progetto: N-01/UFO
        public static FixedPoint UpperClamp(FixedPoint value, FixedPoint upperLimit)
        {
            if (value > upperLimit)
            {
                return(upperLimit);
            }

            return(value);
        }
Esempio n. 29
0
File: Mathfp.cs Progetto: N-01/UFO
        public static FixedPoint Floor(FixedPoint value)
        {
            FixedPoint fraction = value.Fraction();

            if (fraction != 0)
            {
                return(value - value.Fraction() - (FixedPoint)(value > 0 ? 0 : 1));
            }
            return(value);
        }
Esempio n. 30
0
File: Mathfp.cs Progetto: N-01/UFO
        public static FixedPoint Ceiling(FixedPoint value)
        {
            FixedPoint fraction = value.Fraction();

            if (fraction != 0)
            {
                return(value - value.Fraction() + (FixedPoint)(value > 0 ? 1 : 0));
            }
            return(value);
        }
Esempio n. 31
0
    // Update is called once per frame
    public override void DTRMUpdate()
    {
        if ( currentTarget == null )
            return;

        FixedPoint timePassed = DTRM.singleton.dtrmTime - lastAttackTime;

        if ( timePassed < period )
            return;

        FixedPoint targetDistance = ( myPosition.position - currentTarget.myPosition.position ).magnitude;

        if ( targetDistance > attackRange )
            return;

        ApplyDamage();
        lastAttackTime = DTRM.singleton.dtrmTime;
    }
Esempio n. 32
0
 public DTRMVector2(int x = 0, int y = 0)
 {
     this.x = new FixedPoint(x);
     this.y = new FixedPoint(y);
 }
Esempio n. 33
0
 public DTRMVector2(Vector2 vector)
 {
     this.x = new FixedPoint(vector.x);
     this.y = new FixedPoint(vector.y);
 }
Esempio n. 34
0
 public DTRMVector2(float x, float y)
 {
     this.x = new FixedPoint(x);
     this.y = new FixedPoint(y);
 }
Esempio n. 35
0
        public void McCoyTeste()
        {
            N = 100;
            int npassos = 101;
            double passo = 0.1;

            x0 = 125.0;
            xf = 1200.0;

            Integral.Funcao bf = FuncaoBfMcCoy;
            Integral.Funcao an = FuncaoAnMcCoy;
            FixedPoint.FuncaoDupla fp = FuncaofpMcCoy;
            Integral.Funcao D = FuncaoDMcCoy;
            Integral.Funcao funcaoIncial = FuncaoMcCoy;

            FixedPoint fixedPoint = new FixedPoint(N, x0, xf, bf, an, fp, D, funcaoIncial);

            Stopwatch stopwatch = new Stopwatch();

            List<double[]> concentracao = new List<double[]>();

            stopwatch.Start();

            concentracao = fixedPoint.Calcular(npassos, passo);

            Trace.WriteLine(stopwatch.ElapsedMilliseconds);

            stopwatch.Stop();

            autoQuad = new AutoQuad2(10, x0, xf, precisaoRequerida, 15);

            int numeroDePontos = 6;
            var fator = Convert.ToInt32(1.0/passo);
            //var fator = 1;

            var momentosNumericos = new List<double[]>();

            var listaTempo = new List<double>();

            int contador = 0;

            var momentosIniciais = CalcularMomentosIniciaisMcCoy(numeroDePontos, FuncaoMcCoy);

            momentosNumericos.Add(momentosIniciais);

            for (int i = 1; i < fixedPoint.tempo.Length; i += fator)
            {
                contador++;

                var momentos = CalcularMomentos(numeroDePontos, concentracao[i], fixedPoint.x);

                momentosNumericos.Add(momentos);

                listaTempo.Add(contador);

            }

            List<double[]> momentosAnaliticos = CalcularMomentosAnaliticosMcCoy(fixedPoint.tempo, numeroDePontos, momentosIniciais, fator);

            CriarScripParaMatlabConcentracao(@"LaxminaraMcCoy\concentracao", fixedPoint.tempo,fixedPoint.x, concentracao, fator);
            CriarScripParaMatlabMomentos(@"LaxminaraMcCoy\momentos", "A", listaTempo.ToArray(), momentosAnaliticos, momentosNumericos, 1);
        }
Esempio n. 36
0
 public DTRMVector2(Vector3 vector3)
 {
     this.x = new FixedPoint(vector3.x);
     this.y = new FixedPoint(vector3.y);
 }
Esempio n. 37
0
 public static FixedPoint operator -(FixedPoint a, int b)
 {
     FixedPoint result = new FixedPoint();
     result.value = a.value - ( b * fixedPoint );
     return result;
 }
Esempio n. 38
0
        public void Adam2012Teste()
        {
            N = 70;

            double passo = 0.1;
            int npassos = Convert.ToInt32(2.0 / passo + 1);
            npassos = 5;

            kMax = 2.64;
            alfa = 0.35;
            Lmax = 69.5;
            Lmin = 1.0;

            x0 = 0.0;
            xf = kMax;

            Integral.Funcao bf = FuncaoBfAdam2012;
            Integral.Funcao an = FuncaoAnAdam2012;
            FixedPoint.FuncaoDupla fp = FuncaofpAdam2012;
            Integral.Funcao D = FuncaoDAdam2012;
            Integral.Funcao klinha = FuncaoklinhaAdam2012;
            Integral.Funcao funcaoIncial = FuncaoInicialAdam2012;

            autoQuad = new AutoQuad2(10, x0, xf, precisaoRequerida, 10);

            FixedPoint fixedPoint = new FixedPoint(N, x0, xf, bf, an, fp, D, funcaoIncial);

            //fixedPoint.PrepararFp = CalcularS0;

            CalcularS0(kMax);

            Stopwatch stopwatch = new Stopwatch();

            List<double[]> concentracao = new List<double[]>();

            stopwatch.Start();

            concentracao = fixedPoint.Calcular(npassos, passo);

            Trace.WriteLine(stopwatch.ElapsedMilliseconds);

            stopwatch.Stop();

            var fator = 1;

            CriarScripParaMatlabConcentracao(@"LaxminaraAdam2012\concentracao", fixedPoint.tempo,fixedPoint.x, concentracao, fator);
        }
Esempio n. 39
0
 private void IncreaseTime(FixedPoint deltaTime)
 {
     dtrmPreviousStepTime = dtrmTime;
     _dtrmTime += deltaTime;
     _currentStep++;
 }
Esempio n. 40
0
 public override void DTRMStart()
 {
     base.DTRMStart();
     speed = new FixedPoint(defaultSpeed);
 }
Esempio n. 41
0
 public static FixedPoint operator *(FixedPoint a, int b)
 {
     FixedPoint result = new FixedPoint();
     result.value = a.value * b;
     return result;
 }
Esempio n. 42
0
 private static Boolean KawigiEdit_RunTest(int testNum, double p0, double[] p1, double p2, Boolean hasAnswer, double[] p3)
 {
     Console.Write("Test " + testNum + ": [" + p0 + "," + "{");
     for (int i = 0; p1.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write(p1[i]);
     }
     Console.Write("}" + "," + p2);
     Console.WriteLine("]");
     FixedPoint obj;
     double[] answer;
     obj = new FixedPoint();
     DateTime startTime = DateTime.Now;
     answer = obj.find(p0, p1, p2);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.Write("\t" + "{");
         for (int i = 0; p3.Length > i; ++i) {
             if (i > 0) {
                 Console.Write(",");
             }
             Console.Write(p3[i]);
         }
         Console.WriteLine("}");
     }
     Console.WriteLine("Your answer:");
     Console.Write("\t" + "{");
     for (int i = 0; answer.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write(answer[i]);
     }
     Console.WriteLine("}");
     if (hasAnswer) {
         if (answer.Length != p3.Length) {
             res = false;
         } else {
             for (int i = 0; answer.Length > i; ++i) {
                 if (Math.Abs(p3[i] - answer[i]) > 1e-9 * Math.Max(1.0, Math.Abs(p3[i]))) {
                     res = false;
                 }
             }
         }
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
Esempio n. 43
0
 public static FixedPoint operator *(FixedPoint a, FixedPoint b)
 {
     FixedPoint result = new FixedPoint();
     result.value = (a.value * b.value) / fixedPoint;
     return result;
 }
Esempio n. 44
0
 public static FixedPoint operator /(FixedPoint a, long b)
 {
     FixedPoint result = new FixedPoint();
     result.value = a.value / b;
     return result;
 }
Esempio n. 45
0
 public static FixedPoint operator /(FixedPoint a, FixedPoint b)
 {
     FixedPoint result = new FixedPoint();
     result.value = (a.value * fixedPoint) / b.value;
     return result;
 }
Esempio n. 46
0
 public DTRMVector2(FixedPoint x, FixedPoint y)
 {
     this.x = x;
     this.y = y;
 }
Esempio n. 47
0
    private void MoveTowards(DTRMVector2 targetMovePosition, FixedPoint speedPercentage)
    {
        DTRMVector2 desiredVelocity = (targetMovePosition - myPosition.position).normalized;
        desiredVelocity *= speed;
        desiredVelocity *= speedPercentage;
        velocity = desiredVelocity;

        MoveAccordingToSpeed();
    }
Esempio n. 48
0
 public static FixedPoint operator +(FixedPoint a, FixedPoint b)
 {
     FixedPoint result = new FixedPoint();
     result.value = a.value + b.value;
     return result;
 }
Esempio n. 49
0
 public static FixedPoint operator +(FixedPoint a, long b)
 {
     FixedPoint result = new FixedPoint();
     result.value = a.value + ( b * fixedPoint );
     return result;
 }