|
@@ -172,93 +172,97 @@ public class Rectangular_Area_Search_Function
|
|
|
{
|
|
|
line_Perpendicular_Base_left = line_Preparatory;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (line_Perpendicular_Base_left == null || line_Perpendicular_Base_right == null)
|
|
|
- {
|
|
|
- double max_Ditance_left = 0;
|
|
|
- double distance_left = 0;
|
|
|
- double max_Distance_right = 0;
|
|
|
- double distance_right = 0;
|
|
|
+ if (line_Perpendicular_Base_left == null || line_Perpendicular_Base_right == null)
|
|
|
+ {
|
|
|
+ double max_Ditance_left = 0;
|
|
|
+ double distance_left = 0;
|
|
|
+ double max_Distance_right = 0;
|
|
|
+ double distance_right = 0;
|
|
|
|
|
|
- foreach (Point2f m_point in hull)
|
|
|
+ double[] line_inite_Preparatory = GetpPerpendicular(hull[num], Base_line);
|
|
|
+
|
|
|
+ foreach (Point2f m_point in hull)
|
|
|
+ {
|
|
|
+ if (CheckDirection(m_point, line_inite_Preparatory) <= 0)
|
|
|
{
|
|
|
- if (CheckDirection(m_point, line_Preparatory) <= 0)
|
|
|
+ distance_left = GetDistance(m_point, line_inite_Preparatory);
|
|
|
+ if (distance_left > max_Ditance_left)
|
|
|
{
|
|
|
- distance_left = GetDistance(m_point, line_Preparatory);
|
|
|
- if (distance_left > max_Ditance_left)
|
|
|
- {
|
|
|
- max_Ditance_left = distance_left;
|
|
|
- Point_left = m_point;
|
|
|
- line_Perpendicular_Base_left = GetpPerpendicular(Point_left, Base_line);
|
|
|
- }
|
|
|
+ max_Ditance_left = distance_left;
|
|
|
+ Point_left = m_point;
|
|
|
+ line_Perpendicular_Base_left = GetpPerpendicular(Point_left, Base_line);
|
|
|
}
|
|
|
- if (CheckDirection(m_point, line_Preparatory) >= 0)
|
|
|
+ }
|
|
|
+ if (CheckDirection(m_point, line_inite_Preparatory) >= 0)
|
|
|
+ {
|
|
|
+ distance_right = GetDistance(m_point, line_inite_Preparatory);
|
|
|
+ if (distance_right > max_Distance_right)
|
|
|
{
|
|
|
- distance_right = GetDistance(m_point, line_Preparatory);
|
|
|
- if (distance_right > max_Distance_right)
|
|
|
- {
|
|
|
- max_Distance_right = distance_right;
|
|
|
- Point_right = m_point;
|
|
|
- line_Perpendicular_Base_right = GetpPerpendicular(Point_right, Base_line);
|
|
|
- }
|
|
|
+ max_Distance_right = distance_right;
|
|
|
+ Point_right = m_point;
|
|
|
+ line_Perpendicular_Base_right = GetpPerpendicular(Point_right, Base_line);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //foreach (var item in line_Perpendicular_Base_left)
|
|
|
- //{
|
|
|
- // Console.WriteLine("line_Perpendicular_Base_left:" + item);
|
|
|
- //}
|
|
|
+ double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
|
|
|
+ double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
|
|
|
+ double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
|
|
|
+ double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
|
|
|
|
|
|
- //foreach (var item in line_Perpendicular_Base_right)
|
|
|
- //{
|
|
|
- // Console.WriteLine("line_Perpendicular_Base_right:" + item);
|
|
|
- //}
|
|
|
+ double[] temp;
|
|
|
|
|
|
- if (line_Perpendicular_Base_left != null && line_Perpendicular_Base_right != null)
|
|
|
+ if (Point0[0] < Point3[0])
|
|
|
{
|
|
|
- double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
|
|
|
- double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
|
|
|
- double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
|
|
|
- double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
|
|
|
- double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
|
|
|
+ temp = Point0;
|
|
|
+ Point0 = Point3;
|
|
|
+ Point3 = temp;
|
|
|
|
|
|
- if (rectangular_area < min_rectangular_area)
|
|
|
- {
|
|
|
- min_rectangular_area = rectangular_area;
|
|
|
- Point_muster = new List<double[]> {
|
|
|
+ temp = Point1;
|
|
|
+ Point1 = Point2;
|
|
|
+ Point2 = temp;
|
|
|
+ }
|
|
|
+
|
|
|
+ double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
|
|
|
+
|
|
|
+ if (rectangular_area < min_rectangular_area)
|
|
|
+ {
|
|
|
+ min_rectangular_area = rectangular_area;
|
|
|
+ Point_muster = new List<double[]> {
|
|
|
Point0,
|
|
|
Point1,
|
|
|
Point2,
|
|
|
Point3
|
|
|
};
|
|
|
- }
|
|
|
}
|
|
|
- // double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
|
|
|
- // double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
|
|
|
- // double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
|
|
|
- // double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
|
|
|
- // double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
|
|
|
-
|
|
|
- // if (rectangular_area < min_rectangular_area)
|
|
|
- // {
|
|
|
- // min_rectangular_area = rectangular_area;
|
|
|
- // Point_muster = new List<double[]> {
|
|
|
- // Point0,
|
|
|
- // Point1,
|
|
|
- // Point2,
|
|
|
- // Point3
|
|
|
- // };
|
|
|
- // }
|
|
|
+
|
|
|
+
|
|
|
+ //double lat = Rectangular_Area_Search_Function.RMokatuoLat(Point0[0]);
|
|
|
+ //double lon = Rectangular_Area_Search_Function.RMokatuoLon(Point0[1]);
|
|
|
+ //Console.WriteLine("Point0:" + lat + "-" + lon);
|
|
|
+
|
|
|
+ //double lat1 = Rectangular_Area_Search_Function.RMokatuoLat(Point1[0]);
|
|
|
+ //double lon1 = Rectangular_Area_Search_Function.RMokatuoLon(Point1[1]);
|
|
|
+ //Console.WriteLine("Point1:" + lat1 + "-" + lon1);
|
|
|
+
|
|
|
+ //double lat2 = Rectangular_Area_Search_Function.RMokatuoLat(Point2[0]);
|
|
|
+ //double lon2 = Rectangular_Area_Search_Function.RMokatuoLon(Point2[1]);
|
|
|
+ //Console.WriteLine("Point2:" + lat2 + "-" + lon2);
|
|
|
+
|
|
|
+ //double lat3 = Rectangular_Area_Search_Function.RMokatuoLat(Point3[0]);
|
|
|
+ //double lon3 = Rectangular_Area_Search_Function.RMokatuoLon(Point3[1]);
|
|
|
+ //Console.WriteLine("Point3:" + lat3 + "-" + lon3);
|
|
|
}
|
|
|
|
|
|
//foreach (var item in Point_muster)
|
|
|
//{
|
|
|
- // Console.WriteLine("Point_muster:" + item);
|
|
|
- //}
|
|
|
+ // Console.WriteLine("Point_muster:" + item[0] + "-" + item[1]);
|
|
|
+ //}
|
|
|
return Point_muster;
|
|
|
}
|
|
|
}
|