public void substract(CVector2 v) { int n = _size; while ((n--) != 0) { this[n].substract(v); } }
public void add(CVector2 v) { int n = _size; while ((n--) != 0) { this[n].add(v); } }
public CXYVector(int numElem) { _size = numElem; _v = new CVector2[numElem]; while ((numElem--) != 0) { _v[numElem] = new CVector2(); } }
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]); } }
public CXYVector substractCopy(CVector2 v) { CXYVector ret = new CXYVector(this); int n = _size; while ((n--) != 0) { ret[n].substract(v); } return(ret); }
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); }
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); }
public CVector2 substractCopy(CVector2 v) { return(new CVector2(_v[0] - v[0], _v[1] - v[1])); }
public void substract(CVector2 v) { _v[0] -= v[0]; _v[1] -= v[1]; }
public CVector2 addCopy(CVector2 v) { return(new CVector2(_v[0] + v[0], _v[1] + v[1])); }
public void add(CVector2 v) { _v[0] += v[0]; _v[1] += v[1]; }
public CVector2(CVector2 v) { _v[0] = v[0]; _v[1] = v[1]; }