public void QuaternionDGetHashCodeTest() { QuaternionD a = new QuaternionD(1.0f, 2.0f, 3.0f, 4.0f); int expected = unchecked (a.X.GetHashCode() + a.Y.GetHashCode() + a.Z.GetHashCode() + a.W.GetHashCode()); int actual = a.GetHashCode(); Assert.AreEqual(expected, actual); }
/// <summary> /// Hash code for the object. /// </summary> public override int GetHashCode() { var hash = type.GetHashCode(); if (body != null) { hash ^= body.name.GetHashCode(); } hash ^= vesselId.GetHashCode(); if (node != null) { hash ^= node.GetHashCode(); } hash ^= partId.GetHashCode(); if (dockingPort != null) { hash ^= dockingPort.GetHashCode(); } if (thruster != null) { hash ^= thruster.GetHashCode(); } if (parent != null) { hash ^= parent.GetHashCode(); } if (type == ReferenceFrameType.Relative) { hash ^= relativePosition.GetHashCode(); hash ^= relativeRotation.GetHashCode(); hash ^= relativeVelocity.GetHashCode(); hash ^= relativeAngularVelocity.GetHashCode(); } if (type == ReferenceFrameType.Hybrid) { hash ^= hybridPosition.GetHashCode(); hash ^= hybridRotation.GetHashCode(); hash ^= hybridVelocity.GetHashCode(); hash ^= hybridAngularVelocity.GetHashCode(); } return(hash); }
public void HashCode() { QuaternionD q = new QuaternionD(1.0, 2.0, 3.0, 4.0); Assert.AreNotEqual(QuaternionD.Zero.GetHashCode(), q.GetHashCode()); }