public void Set(Vector3D Src) { x = Src.x; y = Src.y; z = Src.z; }
public void ScaleAdd(double r, Vector3D VectorOne) { // The Vector3D is scaled and then another Vector3D is added to it. x = r * x + VectorOne.x; y = r * y + VectorOne.y; z = r * z + VectorOne.z; }
public void ScaleMult(double r, Vector3D VectorOne) { // The Vector3D is scaled and then multiplied by another Vector3D. x = r * x * VectorOne.x; y = r * y * VectorOne.y; z = r * z * VectorOne.z; }
//Vector3D operator-(Vector3D B); // this = pOne - pSubtracted public void Minus(Vector3D One, Vector3D Subtracted) { x = One.x - Subtracted.x; y = One.y - Subtracted.y; z = One.z - Subtracted.z; }
public void Plus(Vector3D One, Vector3D Two) { x = One.x + Two.x; y = One.y + Two.y; z = One.z + Two.z; }
public void GetPerpendicularVector(Vector3D DestVector) { if (x == 0.0f) { DestVector.Set (1.0f, 0.0f, 0.0f); } else if (y == 0.0f) { DestVector.Set (0.0f, 1.0f, 0.0f); } else if (z == 0.0f) { DestVector.Set (0.0f, 0.0f, 1.0f); } else { // pick a vector perpendicular to our original vector // we want ConeDir . PerpVec == 0, so this gives us // -y/x * x + 1 * y + 0 * z == // -y + y + 0 == 0 // // so this vector is perpendicular to our original one if (System.Math.Abs (x) > System.Math.Abs (y)) { if (System.Math.Abs (y) > System.Math.Abs (z)) { // x is the biggest z is the smallest DestVector.Set (z / x, 0.0f, -1.0f); } else { // x is the biggest y is the smallest DestVector.Set (y / x, -1.0f, 0.0f); } // y > x } else if (System.Math.Abs (z) > System.Math.Abs (y)) { // z is the biggest x is the smallest DestVector.Set (-1.0f, 0.0f, x / z); // y > x && z < y } else { // y is the biggest if (x > z) { // y is the biggest z is the smallest DestVector.Set (0.0f, z / y, -1.0f); } else { // y is the biggest x is the smallest DestVector.Set (-1.0f, x / y, 0.0f); } } } }
public Vector3D(Vector3D vector3D) { x = vector3D.x; y = vector3D.y; z = vector3D.z; }
public void EquMax(Vector3D VectorOne, Vector3D VectorTwo) { if (VectorOne.x > VectorTwo.x) x = VectorOne.x; else x = VectorTwo.x; if (VectorOne.y > VectorTwo.y) y = VectorOne.y; else y = VectorTwo.y; if (VectorOne.z > VectorTwo.z) z = VectorOne.z; else z = VectorTwo.z; }
public void EquMin(Vector3D VectorOne, Vector3D VectorTwo) { // set it equal to the min if (VectorOne.x < VectorTwo.x) x = VectorOne.x; else x = VectorTwo.x; if (VectorOne.y < VectorTwo.y) y = VectorOne.y; else y = VectorTwo.y; if (VectorOne.z < VectorTwo.z) z = VectorOne.z; else z = VectorTwo.z; }
public void EquLinComb(double r, Vector3D A, double s, Vector3D B) { // the two Vectors are muliplied by thier own variable scale and then added together x = r * A.x + s * B.x; y = r * A.y + s * B.y; z = r * A.z + s * B.z; }
// are they the same within the error value? public bool Equals(Vector3D OtherVector, double ErrorValue) { if ((x < OtherVector.x + ErrorValue && x > OtherVector.x - ErrorValue) && (y < OtherVector.y + ErrorValue && y > OtherVector.y - ErrorValue) && (z < OtherVector.z + ErrorValue && z > OtherVector.z - ErrorValue)) { return true; } return false; }
public double Dot(Vector3D B) { return (x * B.x + y * B.y + z * B.z); }
public Vector3D Cross(Vector3D B) { Vector3D Temp = new Vector3D (); Temp.Cross (this, B); return Temp; }
public void Cross(Vector3D A, Vector3D B) { x = A.y * B.z - A.z * B.y; y = A.z * B.x - A.x * B.z; z = A.x * B.y - A.y * B.x; }