public void ShouldCalculateCrossProductOfTwoVectors() { PVector aVector = new PVector(3, 4, 5); PVector bVector = new PVector(1, 2, 3); PVector expectedResult = new PVector(2, -4, 2); PVector crossProductVector = aVector.Cross(bVector); Assert.Equal(expectedResult.X, crossProductVector.X); Assert.Equal(expectedResult.Y, crossProductVector.Y); Assert.Equal(expectedResult.Z, crossProductVector.Z); }
public void ShouldStaticallyCalculateCrossProductOfTwoVectorsAndSetTargetVector() { PVector aVector = new PVector(3, 4, 5); PVector bVector = new PVector(1, 2, 3); PVector targetVector = new PVector(6, 7, 8); PVector expectedResult = new PVector(2, -4, 2); PVector crossProductVector = PVector.Cross(aVector, bVector, targetVector); Assert.NotSame(targetVector, expectedResult); Assert.Equal(expectedResult.X, targetVector.X); Assert.Equal(expectedResult.Y, targetVector.Y); Assert.Equal(expectedResult.Z, targetVector.Z); Assert.Equal(expectedResult.X, crossProductVector.X); Assert.Equal(expectedResult.Y, crossProductVector.Y); Assert.Equal(expectedResult.Z, crossProductVector.Z); }
public PVector GetNormal() { PVector edge1 = new PVector(V2.X - V1.X, V2.Y - V1.Y, V2.Z - V1.Z); PVector edge2 = new PVector(V3.X - V1.X, V3.Y - V1.Y, V3.Z - V1.Z); PVector normal = edge1.Cross(edge2); return normal.GetNormalization(); }