コード例 #1
0
        private bool HitsTriangle(Double2 double2, Double2 double3, Double2 double4, Double2 double5,
                                  MutableDouble mutableDouble, MutableDouble mutableDouble2)
        {
            _v0.SetXy(double4.X - double2.X, double4.Y - double2.Y);
            _v1.SetXy(double3.X - double2.X, double3.Y - double2.Y);
            _v2.SetXy(double5.X - double2.X, double5.Y - double2.Y);
            var dot  = Dot(_v0, _v0);
            var dot2 = Dot(_v0, _v1);
            var dot3 = Dot(_v0, _v2);
            var dot4 = Dot(_v1, _v1);
            var dot5 = Dot(_v1, _v2);
            var n    = dot * dot4 - dot2 * dot2;

            if (n != 0.0)
            {
                mutableDouble.Value  = (dot4 * dot3 - dot2 * dot5) / n;
                mutableDouble2.Value = (dot * dot5 - dot2 * dot3) / n;
            }
            else
            {
                var n2 = 0.0;
                mutableDouble2.Value = n2;
                mutableDouble.Value  = n2;
            }

            return(mutableDouble.Value + mutableDouble2.Value < 1.0 && mutableDouble.Value > 0.0 &&
                   mutableDouble2.Value > 0.0);
        }
コード例 #2
0
        private bool HitsCircleAroundOrigin(double n, Double2 double2, MutableDouble mutableDouble)
        {
            if (Math.Abs(n) <= VariationHelper.SmallDouble)
            {
                return(true);
            }

            mutableDouble.Value = Math.Sqrt(VariationHelper.Sqr(double2.X) + VariationHelper.Sqr(double2.Y));
            return(mutableDouble.Value <= n);
        }
コード例 #3
0
        public override void Init()
        {
            _xy       = new Double2();
            _r        = new MutableDouble();
            _u        = new MutableDouble();
            _v        = new MutableDouble();
            _double2A = new Double2();
            _double2B = new Double2();
            _double2C = new Double2();
            _double2D = new Double2();
            _double2E = new Double2();
            _double2F = new Double2();
            _double2G = new Double2();
            _double2H = new Double2();
            _double2I = new Double2();
            _double2J = new Double2();
            _double2K = new Double2();
            _double2L = new Double2();
            _v0       = new Double2();
            _v1       = new Double2();
            _v2       = new Double2();

            _polarWeight = P1;
            _radius      = P2;
            _s           = P3;
            _t           = P4;


            _a   = _s * 0.5 + _t;
            _rad = 0.707106781 * _s * Math.Abs(_radius);
            _ax  = -0.5 * _s;
            _ay  = 0.5 * _s + _t;
            _bx  = 0.5 * _s;
            _by  = 0.5 * _s + _t;
            _cx  = _t;
            _cy  = 0.5 * _s;
            _dx  = _t;
            _dy  = -0.5 * _s;
            _ex  = 0.5 * _s;
            _ey  = -0.5 * _s - _t;
            _fx  = -0.5 * _s;
            _fy  = -0.5 * _s - _t;
            _gx  = -_t;
            _gy  = -0.5 * _s;
            _hx  = -_t;
            _hy  = 0.5 * _s;
            _ix  = -0.5 * _s;
            _iy  = 0.5 * _s;
            _jx  = 0.5 * _s;
            _jy  = 0.5 * _s;
            _kx  = -0.5 * _s;
            _ky  = -0.5 * _s;
            _lx  = 0.5 * _s;
            _ly  = -0.5 * _s;
            _double2A.SetXy(_ax, _ay);
            _double2B.SetXy(_bx, _by);
            _double2C.SetXy(_cx, _cy);
            _double2D.SetXy(_dx, _dy);
            _double2E.SetXy(_ex, _ey);
            _double2F.SetXy(_fx, _fy);
            _double2G.SetXy(_gx, _gy);
            _double2H.SetXy(_hx, _hy);
            _double2I.SetXy(_ix, _iy);
            _double2J.SetXy(_jx, _jy);
            _double2K.SetXy(_kx, _ky);
            _double2L.SetXy(_lx, _ly);
        }