public void Intersect_TwoPoints() { var line = new Line3(); var sphere = new Sphere(); foreach (var center in originPoints3) { sphere.center = center; for (int radius = 1; radius < 12; radius += 10) { sphere.radius = radius; foreach (var direction in directionPoints3) { line.direction = direction; line.origin = center; Vector3 point1 = line.GetPoint(-sphere.radius); Vector3 point2 = line.GetPoint(sphere.radius); True_Intersect(line, sphere, point1, point2); line.origin = center - line.direction; True_Intersect(line, sphere, point1, point2); line.origin = center + line.direction; True_Intersect(line, sphere, point1, point2); } } } }
public void ClosestPoints_TwoPoints() { var line = new Line3(); var sphere = new Sphere(); foreach (var center in originPoints3) { sphere.center = center; for (int radius = 1; radius < 12; radius += 10) { sphere.radius = radius; foreach (var direction in directionPoints3) { line.direction = direction; line.origin = center; Vector3 point = line.GetPoint(-radius); AreEqual_ClosestPoints(line, sphere, point, point); line.origin = center - line.direction; AreEqual_ClosestPoints(line, sphere, point, point); line.origin = center + line.direction; AreEqual_ClosestPoints(line, sphere, point, point); } } } }
public void ClosestPoint_PointNotOnLine() { var line = new Line3(); foreach (var origin in originPoints3) { foreach (var direction in directionPoints3) { line.origin = origin; line.direction = direction; Vector3 tangent = GetTangent(direction); for (int perpendicularAngle = 0; perpendicularAngle < 360; perpendicularAngle += 10) { Vector3 perpendicular = Quaternion.AngleAxis(perpendicularAngle, direction) * tangent; 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)); } } } }