public void Area() { var expected = Math.PI; var c = new Point2double(1, 1); var r = 1; var actual = new Circle2double(c, r).Area; Assert.Equal(expected, actual); }
public void OperatorEqualsTrue() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var l1 = new Line2double(p1, p2); var l2 = new Line2double(p1, p2); Assert.True(l1 == l2); }
public void YInterceptLine() { var expected = 0.5; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 5); var actual = new Line2double(p1, p2).YIntercept(); Assert.Equal(expected, actual); }
public void Length() { var expected = 3.605551; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 5); var actual = new Line2double(p1, p2).Length(); Assert.Equal(expected, actual, 6); }
public void GetHashCodeTest() { var expected = 2145910784; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var actual = new Line2double(p1, p2).GetHashCode(); Assert.Equal(expected, actual); }
public void Line2doubleConstructorPointPoint() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var actual = new Line2double(p1, p2); Assert.Equal(p1, actual.P1); Assert.Equal(p2, actual.P2); }
public void EqualsLine2doubleTrue() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var l1 = new Line2double(p1, p2); var l2 = new Line2double(p1, p2); Assert.True(l1.Equals(l2)); }
public void Slope() { var expected = 0.5; var p1 = new Point2double(1, 2); var p2 = new Point2double(0, 1.5); var actual = new Line2double(p1, p2).Slope(); Assert.Equal(expected, actual); }
public void Circle2doubleConstructor() { var c = new Point2double(1, 1); var r = 1; var actual = new Circle2double(c, r); Assert.Equal(c, actual.C); Assert.Equal(r, actual.R); }
public void Circumfrence() { var expected = 2 * Math.PI; var c = new Point2double(1, 1); var r = 1; var actual = new Circle2double(c, r).Circumfrence; Assert.Equal(expected, actual); }
public void ToStringTest() { var expected = "(1, 1) R = 1"; var c = new Point2double(1, 1); var r = 1; var actual = new Circle2double(c, r).ToString(); Assert.Equal(expected, actual); }
public void ToStringTest() { var expected = "((1, 2), (3, 4))"; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var actual = new Line2double(p1, p2).ToString(); Assert.Equal(expected, actual); }
public void OperatorNotEqualsFalse() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var l1 = new Line2double(p1, p2); var l2 = new Line2double(p1, p2); Assert.False(l1 != l2); }
public void OperatorNotEqualsFalse() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var p3 = new Point2double(5, 6); var t1 = new Triangle2double(p1, p2, p3); var t2 = new Triangle2double(p1, p2, p3); Assert.False(t1 != t2); }
public void ToStringTest() { var expected = "(1, 1) A = 2, B = 1"; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).ToString(); Assert.Equal(expected, actual); }
public void Perimeter() { var expected = 9.688448220506999; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).Perimeter; Assert.Equal(expected, actual); }
public void PerimeterFast() { var expected = 9.688448216130086; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).PerimeterFast; Assert.Equal(expected, actual); }
public void h() { var expected = 0.1111111111111111; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).h; Assert.Equal(expected, actual); }
public void Eccentricity() { var expected = 0.8660254037844386; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).Eccentricity; Assert.Equal(expected, actual); }
public void EqualsLine2doubleFalse() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var p3 = new Point2double(5, 5); var l1 = new Line2double(p1, p2); var l2 = new Line2double(p1, p3); Assert.False(l1.Equals(l2)); }
public void GetHashCodeTest() { var expected = 2145648640; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var p3 = new Point2double(5, 6); var actual = new Triangle2double(p1, p2, p3).GetHashCode(); Assert.Equal(expected, actual); }
public static Point2double ReflectPoint(this Line2double l, Point2double p) { var m = l.Slope(); var c = l.YIntercept(); var d = (p.X + (p.Y - c) * m) / (1 + m * m); var x = 2 * d - p.X; var y = 2 * d * m - p.Y + 2 * c; return(new(x, y)); }
public static double Distance(Point2double p1, Point2double p2) { var dx = p2.X - p1.X; var dy = p2.Y - p1.Y; var dx2 = dx * dx; var dy2 = dy * dy; return(Math.Sqrt(dx2 + dy2)); }
public void ToStringTest() { var expected = "((1, 2), (3, 4), (5, 6))"; var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var p3 = new Point2double(5, 6); var actual = new Triangle2double(p1, p2, p3).ToString(); Assert.Equal(expected, actual); }
public void Area() { var expected = Math.PI * 2; var c = new Point2double(1, 1); var a = 2; var b = 1; var actual = new Ellipse2double(c, a, b).Area; Assert.Equal(expected, actual); }
public void EqualsTriangle2doubleTrue() { var p1 = new Point2double(1, 2); var p2 = new Point2double(3, 4); var p3 = new Point2double(5, 6); var t1 = new Triangle2double(p1, p2, p3); var t2 = new Triangle2double(p1, p2, p3); Assert.True(t1.Equals(t2)); }
public void ReflectPoint() { var expected = new Point2double(0.2, 2.6); var p1 = new Point2double(1, 2); var p2 = new Point2double(0, 1.5); var p3 = new Point2double(1, 1); var actual = new Line2double(p1, p2).ReflectPoint(p3); Assert.Equal(expected, actual); }
public void Area() { var expected = 1.5; var p1 = new Point2double(0, 0); var p2 = new Point2double(1, 1); var p3 = new Point2double(3, 0); var actual = new Triangle2double(p1, p2, p3).Area(); Assert.Equal(expected, actual); }
public void Line2doubleConstructorPointSlope() { var p1 = new Point2double(1, 2); var p2 = new Point2double(0, 1.5); var slope = 0.5; var actual = new Line2double(p1, slope); Assert.Equal(p1, actual.P1); Assert.Equal(p2, actual.P2); }
public Line2double(Point2double p1, double m) : this() { P1 = p1; P2 = new(0, p1.YIntercept(m)); if (P1 == P2) { throw new ArithmeticException("Point is Y intercept"); } }