public void setVector(clsVector vector) { setVector(vector.x, vector.y, vector.z); }
public void add(clsVector Vector) { this.x += Vector.x; this.y += Vector.y; this.z += Vector.z; }
public clsVector bisection2d(clsVector vector) { clsVector t = this.normalized; clsVector v = vector.normalized; if ((t.x == v.x) || (t.y == v.y)) { // return the perpendicular of collinear vectors return perpendicular2d; } else return (t + v).normalized; }
public clsVector rotate2d(float degrees) { clsVector result = new clsVector(this.x, this.y, this.z); result.x = this.x * (float)Math.Cos(degrees) - this.y * (float)Math.Sin(degrees); result.y = this.x * (float)Math.Sin(degrees) - this.y * (float)Math.Cos(degrees); return result; }
public clsVector reflection(clsVector vector) { // R = V - 2 * (V . N) * N clsVector n = vector.normalized; // n must be normalized return this - (n * (2 * this.dotProduct(n))); }
public float dotProduct(clsVector vector) { return this.dotProduct(this, vector); }
public float dotProduct(clsVector vectorA, clsVector vectorB) { return vectorA.x * vectorB.x + vectorA.y * vectorB.y + vectorA.z * vectorB.z; }
public clsVector crossProduct(clsVector vector) { return this.crossProduct(this, vector); }
// returns a vector that is perpendicular to the plane created by this and the passed vector public clsVector crossProduct(clsVector vectorA, clsVector vectorB) { return new clsVector(vectorA.y * vectorB.z - vectorA.z * vectorB.y, vectorA.z * vectorB.x - vectorA.x * vectorB.z, vectorA.x * vectorB.y - vectorA.y * vectorB.x); }