public void Op_NotEquals() { var p1 = new Point3double(1, 2, 3); var p2 = new Point3double(1, 2, 4); Assert.True(p1 != p2); }
/// <summary> /// Determines if the points p1 and p2 are on the same side of the line through points a and b /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private static bool SameSide(Point3double p1, Point3double p2, Point3double a, Point3double b) { var cp1 = (b - a).Cross(p1 - a); var cp2 = (b - a).Cross(p2 - a); return(cp1.Dot(cp2) >= 0); }
public void Equals2() { var p1 = new Point3double(1, 2, 3); var p2 = new Point3double(1, 2, 3); Assert.Equal(p1, p2); }
public void Point3double() { var p = new Point3double(1, 2, 3); Assert.Equal(1, p.X); Assert.Equal(2, p.Y); Assert.Equal(3, p.Z); }
public void GetHashCodeTest() { var expected = 1073217536; var p = new Point3double(1, 2, 3); var actual = p.GetHashCode(); Assert.Equal(expected, actual); }
public void ToStringTest() { var expected = "(1, 2, 3)"; var p = new Point3double(1, 2, 3); var actual = p.ToString(); Assert.Equal(expected, actual); }
public void Cross() { var expected = new Point3double(-1, 2, -1); var p1 = new Point3double(1, 2, 3); var p2 = new Point3double(2, 3, 4); var actual = p1.Cross(p2); Assert.Equal(expected, actual); }
public void Dot() { var expected = 20; var p1 = new Point3double(1, 2, 3); var p2 = new Point3double(2, 3, 4); var actual = p1.Dot(p2); Assert.Equal(expected, actual); }
public static Point3double Cross(this Point3double p1, Point3double p2) =>
/// <summary> /// Determines if the point p lies inside the triangle defined by the points a, b, c /// </summary> /// <param name="p"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <returns></returns> public static bool IsPointInTriangle(Point3double p, Point3double a, Point3double b, Point3double c) => SameSide(p, a, b, c) && SameSide(p, b, a, c) && SameSide(p, c, a, b);
public void EqualsTest() { var p = new Point3double(1, 2, 3); Assert.False(p.Equals(1)); }