public void IsWithinShape_Of_Polyline_Throws_Argument_Exception() { Point coordinate = new Point(1, 1); Assert.That(() => PointIntersection.IsWithinShape(coordinate, polyline.ToArray()), Throws.Exception .TypeOf <ArgumentException>()); }
public void TestMethodSolvePointIntersect() { PointIntersection pit = new PointIntersection(new System.Collections.Generic.List <ElementBase> { l0550, l0055 }); Trace.WriteLine(pit.Point.Get <double>(0)); }
private void button5_Click(object sender, EventArgs e) { //Given two line segements and find whether these two lines interesect //Each line consist of two MathPoints start and end //so given four MathPoints where p1 and q1 form a line and p2 and q2 form another line MathPoint p1 = new MathPoint(10, 0); MathPoint q1 = new MathPoint(0, 10); MathPoint p2 = new MathPoint(0, 0); MathPoint q2 = new MathPoint(10, 0); //bool result = DoLinesIntersect(p1, q1, p2, q2); PointIntersection pi = new PointIntersection(); bool result = pi.DoLinesIntersect(p1, q1, p2, q2); }
private void button7_Click(object sender, EventArgs e) { MathPoint p1 = new MathPoint(1, 1); MathPoint p2 = new MathPoint(4, 4); MathPoint p3 = new MathPoint(5, 5); MathPoint p4 = new MathPoint(2, 5); MathPoint p5 = new MathPoint(6, 3); List <MathPoint> points = new List <MathPoint>(); points.Add(p1); points.Add(p2); points.Add(p3); points.Add(p4); points.Add(p5); MathPoint[] pointsarray = points.ToArray(); PointIntersection obj = new PointIntersection(); Line bestline = obj.FindBestLine(pointsarray); }
private void button12_Click(object sender, EventArgs e) { //Given two line segements and find whether these two lines interesect //Gayle 6th edition page 464 //so given four MathPoints where p1 and q1 form a line and p2 and q2 form another line MathPoint p1 = new MathPoint(10, 0); MathPoint q1 = new MathPoint(0, 10); MathPoint p2 = new MathPoint(0, 0); MathPoint q2 = new MathPoint(10, 0); PointIntersection pi = new PointIntersection(); MathPoint result = pi.GetIntersectionPointUsingSlopes(p1, q1, p2, q2); if (result != null) { //we found intersction point } }
/// <summary> /// Determines whether [is any point on segment and not ends] [the specified polyline]. /// </summary> /// <param name="polyline">The polyline.</param> /// <returns><c>true</c> if [is any point on segment and not ends] [the specified polyline]; otherwise, <c>false</c>.</returns> public static bool IsJoiningPointOnAnotherSegment(PolyLine polyline) { CartesianCoordinate firstPoint = polyline.FirstPoint(); CartesianCoordinate lastPoint = polyline.LastPoint(); for (int i = 1; i < polyline.CountSegments - 1; i++) { // Loop is skipping first and last segments if (polyline[i] is LineSegment) { LineSegment segment = (LineSegment)polyline[i]; if ((segment.IncludesCoordinate(firstPoint) && !PointIntersection.IsOnPoint(firstPoint, segment.I) && !PointIntersection.IsOnPoint(firstPoint, segment.J)) || (segment.IncludesCoordinate(lastPoint) && !PointIntersection.IsOnPoint(lastPoint, segment.I) && !PointIntersection.IsOnPoint(lastPoint, segment.J))) { return(true); } } } return(false); }
/// <summary> /// Adds the formation to the region if the coordinates lie within the region shape. /// </summary> /// <param name="formation">The location.</param> public bool AddFormationByCoordinates(Formation formation) { if (!IsBaseShape()) { foreach (CompositeShape <Coordinate, Boundary, Extents> shape in this) { Region region = shape as Region; bool? result = region?.AddFormationByCoordinates(formation); if (result.HasValue && result.Value) { return(true); } } } if (!isWithinExtents(formation) || !PointIntersection.IsWithinShape(new Point(formation.Longitude, formation.Latitude), Boundary.Select(coordinate => (Point)coordinate).ToArray())) { return(false); } _formationsBase.Add(formation); return(true); }
public static void NumberOfIntersectionsOnHorizontalProjection_Of_Polyline_Throws_Argument_Exception_for_Path() { CartesianCoordinate coordinate = new CartesianCoordinate(1, 1); Assert.Throws <ArgumentException>(() => PointIntersection.IsWithinShape(coordinate, polyline.ToArray())); }
public bool IsWithinShape_Between_Top_And_Bottom_of_Square(double x) { Point coordinate = new Point(x, 1); return(PointIntersection.IsWithinShape(coordinate, square.ToArray())); }
public bool IsWithinShape_Aligned_With_Top_of_Square(double x) { Point coordinate = new Point(x, 5); return(PointIntersection.IsWithinShape(coordinate, square.ToArray())); }
[TestCase(1, -2, 1, -2, ExpectedResult = true)] // On public bool PointsOverlap(double x, double y, double x1, double y1) { Point point = new Point(x1, y1); return(PointIntersection.PointsOverlap(point, new Point(x, y))); }
[TestCase(1, -2, 1, -2, ExpectedResult = true)] // On public static bool IsOnPoint(double x, double y, double x1, double y1) { CartesianCoordinate point = new CartesianCoordinate(x1, y1); return(PointIntersection.IsOnPoint(point, new CartesianCoordinate(x, y))); }
public bool IsWithinShape_Intersection_Multiple_Solid_Void_On_Tooth_Segment(double x) { Point coordinate = new Point(x, -5); return(PointIntersection.IsWithinShape(coordinate, comb.ToArray())); }
public bool IsWithinShape_Above_Square(double x) { Point coordinate = new Point(x, 6); return(PointIntersection.IsWithinShape(coordinate, square.ToArray())); }
[TestCase(0, -2.1, false)] // Outside path but inside re-entrant corner, not aligned with tips public static void NumberOfIntersectionsOnHorizontal_Star(double x, double y, bool expectedResult) { CartesianCoordinate point = new CartesianCoordinate(x, y); Assert.AreEqual(expectedResult, PointIntersection.IsWithinShape(point, star.ToArray())); }
[TestCase(0, -2.1, false)] // Outside path but inside re-entrant corner, not aligned with tips public static void IsOnBoundary_Star(double x, double y, bool expectedResult) { CartesianCoordinate point = new CartesianCoordinate(x, y); Assert.AreEqual(expectedResult, PointIntersection.IsOnBoundary(point, star.ToArray())); }
public static void IsWithinShape_Of_Polyline_Throws_Argument_Exception() { CartesianCoordinate coordinate = new CartesianCoordinate(1, 1); Assert.Throws <ArgumentException>(() => PointIntersection.IsWithinShape(coordinate, polyline.ToArray())); }