public void HorizontalConstraintShouldWork() { var line = new Line(new Point(0, 1, false), new Point(2, 3, false, true) ); var error = SketchSolve.Solver.solve (true , line.IsHorizontal() ); error.Should ().BeApproximately (0, 0.0001); line.p1.y.Value.Should().BeApproximately(line.p2.y.Value, 0.001); }
public void TangentToCircleConstraintWithLineInitiallyHorizontalShouldWork() { // Create a fully constrained circle at 0,0 with radius 1 var circle = new Circle() { center = new Point(0, 0, false), rad = new Parameter(10, false) }; var v = -15; var line = new Line(new Point(-100, -v, false, true), new Point(100, -v*2.1, false, true)); var r = SketchSolve.Solver.solve ( true , line.IsTangentTo(circle) , line.IsHorizontal() ); Console.WriteLine (line); Console.WriteLine (circle); (circle.CenterTo (line).Vector.LengthSquared - circle.rad.Value*circle.rad.Value) .Should () .BeApproximately (0, 0.001); }