public void ClosestPoints_Parallel() { var line = new Line2(); var ray = new Ray2D(); foreach (var origin in originPoints2) { foreach (var direction in directionPoints2) { Vector2 perpendicular = direction.RotateCW90(); line.origin = origin; line.direction = direction; ray.direction = direction; ray.origin = origin + perpendicular - direction * 30; AreEqual_ClosestPoints(line, ray, line.GetPoint(-30), ray.origin); ray.origin = origin + perpendicular - direction; AreEqual_ClosestPoints(line, ray, origin - direction, ray.origin); ray.origin = origin + perpendicular; AreEqual_ClosestPoints(line, ray, origin, ray.origin); ray.origin = origin + perpendicular + direction; AreEqual_ClosestPoints(line, ray, origin + direction, ray.origin); ray.origin = origin + perpendicular + direction * 30; AreEqual_ClosestPoints(line, ray, line.GetPoint(30), ray.origin); } } }
public void ClosestPoints_Parallel() { var line = new Line2(); var segment = new Segment2(); foreach (var origin in originPoints2) { foreach (var direction in directionPoints2) { Vector2 perpendicular = direction.RotateCW90(); line.origin = origin; line.direction = direction; segment.a = origin + perpendicular - direction * 50; segment.b = origin + perpendicular - direction; AreEqual_ClosestPoints(line, segment, line.GetPoint(-50), segment.a); segment.a = origin + perpendicular - direction * 2; segment.b = origin + perpendicular; AreEqual_ClosestPoints(line, segment, line.GetPoint(-2), segment.a); segment.a = origin + perpendicular - direction; segment.b = origin + perpendicular + direction; AreEqual_ClosestPoints(line, segment, line.GetPoint(-1), segment.a); segment.a = origin + perpendicular; segment.b = origin + perpendicular + direction * 2; AreEqual_ClosestPoints(line, segment, line.origin, segment.a); segment.a = origin + perpendicular + direction; segment.b = origin + perpendicular + direction * 50; AreEqual_ClosestPoints(line, segment, line.GetPoint(1), segment.a); } } }
public void Intersect_TwoPoints() { var line = new Line2(); var circle = new Circle2(); foreach (var center in originPoints2) { circle.center = line.origin = center; for (int radius = 1; radius < 22; radius += 10) { circle.radius = radius; foreach (var direction in directionPoints2) { line.direction = direction; True_Intersect(line, circle, line.GetPoint(-circle.radius), line.GetPoint(circle.radius)); } } } }
public void Distance_Parallel() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; lineB.origin = lineA.GetPoint(30) + lineA.direction.RotateCCW90(); AreEqual_DistanceSwap(lineA, lineB, 1); lineB.direction = -lineB.direction; AreEqual_DistanceSwap(lineA, lineB, 1); } } }
public void Distance_Collinear() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; lineB.origin = lineA.GetPoint(100); AreEqual_DistanceSwap(lineA, lineB); lineB.direction = -lineB.direction; AreEqual_DistanceSwap(lineA, lineB); } } }
public void Intersect_Collinear() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; lineB.origin = lineA.GetPoint(50); Intersect_LineSwap(lineA, lineB); lineB.direction = -lineB.direction; Intersect_LineSwap(lineA, lineB); } } }
public void Intersect_Parallel() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; Vector2 perpendicular = lineA.direction.RotateCCW90(); lineB.origin = lineA.GetPoint(30) + perpendicular; IsFalse_Intersect(lineA, lineB); lineB.direction = -lineB.direction; IsFalse_Intersect(lineA, lineB); } } }
public void ClosestPoints_Collinear() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; lineB.origin = lineA.GetPoint(50); AreEqual_ClosestPoints(lineA, lineB, lineA.origin); AreEqual_ClosestPoints(lineB, lineA, lineB.origin); lineB.direction = -lineB.direction; AreEqual_ClosestPoints(lineA, lineB, lineA.origin); AreEqual_ClosestPoints(lineB, lineA, lineB.origin); } } }
public void ClosestPoints_Parallel() { var lineA = new Line2(); var lineB = new Line2(); foreach (var origin in originPoints2) { lineA.origin = origin; foreach (var direction in directionPoints2) { lineA.direction = lineB.direction = direction; Vector2 perpendicular = lineA.direction.RotateCCW90(); lineB.origin = lineA.GetPoint(30) + perpendicular; AreEqual_ClosestPoints(lineA, lineB, lineA.origin, lineA.origin + perpendicular); AreEqual_ClosestPoints(lineB, lineA, lineB.origin, lineB.origin - perpendicular); lineB.direction = -lineB.direction; AreEqual_ClosestPoints(lineA, lineB, lineA.origin, lineA.origin + perpendicular); AreEqual_ClosestPoints(lineB, lineA, lineB.origin, lineB.origin - perpendicular); } } }
public void ClosestPoint_PointNotOnLine() { var line = new Line2(); foreach (var origin in originPoints2) { foreach (var direction in directionPoints2) { Vector2 perpendicular = direction.RotateCW90(); line.origin = origin; line.direction = direction; AreEqual_ClosestPoint(line, origin + perpendicular, origin); AreEqual_ClosestPoint(line, origin + perpendicular + direction * offset, line.GetPoint(offset)); AreEqual_ClosestPoint(line, origin + perpendicular - direction * offset, line.GetPoint(-offset)); } } }