예제 #1
0
        public void substract(CVector2 v)
        {
            int n = _size;

            while ((n--) != 0)
            {
                this[n].substract(v);
            }
        }
예제 #2
0
        public void add(CVector2 v)
        {
            int n = _size;

            while ((n--) != 0)
            {
                this[n].add(v);
            }
        }
예제 #3
0
        public CXYVector(int numElem)
        {
            _size = numElem;
            _v    = new CVector2[numElem];

            while ((numElem--) != 0)
            {
                _v[numElem] = new CVector2();
            }
        }
예제 #4
0
        public CXYVector(CXYVector v)
        {
            int i;

            _size = v.size;
            _v    = new CVector2[_size];
            for (i = 0; i < _size; i++)
            {
                _v[i] = new CVector2(v[i]);
            }
        }
예제 #5
0
        public CXYVector substractCopy(CVector2 v)
        {
            CXYVector ret = new CXYVector(this);
            int       n   = _size;

            while ((n--) != 0)
            {
                ret[n].substract(v);
            }

            return(ret);
        }
예제 #6
0
        public double distance(CXYVector target)
        {
            double res  = 0f;
            int    size = _size;

            while ((size--) != 0)
            {
                CVector2 temp = _v[size].substractCopy(target[size]);
                res += temp.length2();
            }

            return(res);
        }
예제 #7
0
        public static CVector2 vNormal(CVector2 p0, CVector2 p1, CVector2 p2)
        {
            CVector2 p, q, d;

            d = p1.substractCopy(p0);
            p = new CVector2(d[1], -d[0]);

            d = p2.substractCopy(p1);
            q = new CVector2(d[1], -d[0]);

            p.add(q);
            p.divide(Math.Sqrt(p[0] * p[0] + p[1] * p[1]));
            return(p);
        }
예제 #8
0
 public CVector2 substractCopy(CVector2 v)
 {
     return(new CVector2(_v[0] - v[0], _v[1] - v[1]));
 }
예제 #9
0
 public void substract(CVector2 v)
 {
     _v[0] -= v[0];
     _v[1] -= v[1];
 }
예제 #10
0
 public CVector2 addCopy(CVector2 v)
 {
     return(new CVector2(_v[0] + v[0], _v[1] + v[1]));
 }
예제 #11
0
 public void add(CVector2 v)
 {
     _v[0] += v[0];
     _v[1] += v[1];
 }
예제 #12
0
 public CVector2(CVector2 v)
 {
     _v[0] = v[0];
     _v[1] = v[1];
 }