/// <summary> /// When two vectors are parallel, the cross product cannot be normalised. This method hacks around that problem. /// </summary> /// <returns>A UnitVector</returns> /// <param name="aVector">A second vector to which the result will be orthogonal.</param> public UnitVector safeNormalisedCrossProduct(Scientrace.Vector aVector) { if (this.length * aVector.length == 0) { return(UnitVector.x1vector()); } Vector crossVector = this.crossProduct(aVector); if (crossVector.length == 0) { return(this.safeNormalisedCrossProduct(aVector.vectorDance())); } return(crossVector.tryToUnitVector()); }