|
@@ -3,25 +3,49 @@ import java.util.ArrayList;
|
|
|
public class CalculateArea {
|
|
|
ArrayList<Double> Pointx_input;
|
|
|
ArrayList<Double> Pointy_input;
|
|
|
+
|
|
|
+ ArrayList<Double> Pointx_input_initial;
|
|
|
+ ArrayList<Double> Pointy_input_initial;
|
|
|
+
|
|
|
ArrayList<Double> Row_input;
|
|
|
ArrayList<Double> Theta_input;
|
|
|
ArrayList<Double> centerx_history;
|
|
|
ArrayList<Double> centery_history;
|
|
|
+ ArrayList<DataType<Double>> Result_Row = new ArrayList<>();
|
|
|
+ ArrayList<DataType<Double>> Result_Theta = new ArrayList<>();
|
|
|
double FinalCenterX;
|
|
|
double FinalCenterY;
|
|
|
double RusedforMeanShift;
|
|
|
+ double SplitTheta;
|
|
|
+ double SplitRadiusWidth;
|
|
|
+ double IncreasingRate;
|
|
|
+
|
|
|
|
|
|
public CalculateArea(ArrayList<Double> Pointx_input,ArrayList<Double> Pointy_input,ArrayList<Double> centerx_history,ArrayList<Double> centery_history){
|
|
|
- this.Pointx_input = Pointx_input;
|
|
|
- this.Pointy_input = Pointy_input;
|
|
|
+ this.Pointx_input_initial = Pointx_input;
|
|
|
+ this.Pointy_input_initial = Pointy_input;
|
|
|
this.centerx_history = centerx_history;
|
|
|
this.centery_history = centery_history;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void setRusedforMeanShift(double RusedforMeanShift){
|
|
|
this.RusedforMeanShift = RusedforMeanShift;
|
|
|
}
|
|
|
|
|
|
+ public void setSplitTheta(double SplitTheta){
|
|
|
+ this.SplitTheta = SplitTheta;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSplitRadiusWidth(double SplitRadiusWidth){
|
|
|
+ this.SplitRadiusWidth = SplitRadiusWidth;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setIncreasingRate(double IncreasingRate){
|
|
|
+ this.IncreasingRate = IncreasingRate;
|
|
|
+ }
|
|
|
+
|
|
|
public void DktoPolar(){
|
|
|
for(int i = 0 ;i < Pointx_input.size();i++){
|
|
|
double Theta = 0;
|
|
@@ -57,15 +81,15 @@ public class CalculateArea {
|
|
|
|
|
|
public void configFinalCircle(){
|
|
|
int IndexofMax;
|
|
|
- IndexofMax = Compare(RusedforMeanShift)
|
|
|
+ IndexofMax = Compare(RusedforMeanShift);
|
|
|
FinalCenterX = centerx_history.get(IndexofMax);
|
|
|
FinalCenterY = centery_history.get(IndexofMax);
|
|
|
}
|
|
|
|
|
|
public double FindPointinsideR(double centerx,double centery,double R){
|
|
|
ArrayList<Integer> NuminsideR = new ArrayList<>();
|
|
|
- for(int i = 0 ; i < Pointx_input.size() ; i++){
|
|
|
- if (CalculateDistance(Pointx_input.get(i),Pointy_input.get(i),centerx,centery) < R){
|
|
|
+ for(int i = 0 ; i < Pointx_input_initial.size() ; i++){
|
|
|
+ if (CalculateDistance(Pointx_input_initial.get(i),Pointy_input_initial.get(i),centerx,centery) < R){
|
|
|
NuminsideR.add(i);
|
|
|
}
|
|
|
}
|
|
@@ -76,5 +100,67 @@ public class CalculateArea {
|
|
|
return Math.sqrt(Math.pow((x1-x2),2) + Math.pow((y1-y2),2));
|
|
|
}
|
|
|
|
|
|
+ public void exchange(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void LoopforCalculateArea(){
|
|
|
+ ArrayList<Double> Row_input_forcal = new ArrayList<>(Row_input);
|
|
|
+ ArrayList<Double> Theta_input_forcal = new ArrayList<>(Theta_input);
|
|
|
+ ArrayList<Double> AngleArrangeList = new ArrayList<>();
|
|
|
|
|
|
+ for(int i = 0 ; i < 2 * Math.PI / SplitTheta ;i++){
|
|
|
+ AngleArrangeList.add(SplitTheta * i);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0 ; i < AngleArrangeList.size() ; i++){
|
|
|
+ ArrayList<Double> Row_input_temp = new ArrayList<>();
|
|
|
+ ArrayList<Double> Theta_input_temp = new ArrayList<>();
|
|
|
+ for(int j = 0 ; j < Theta_input_forcal.get(i) ; j++){
|
|
|
+ if(Theta_input_forcal.get(i) > AngleArrangeList.get(i) && Theta_input_forcal.get(i) < (AngleArrangeList.get(i) + SplitTheta )){
|
|
|
+ Row_input_temp.add(Row_input_forcal.get(i));
|
|
|
+ Theta_input_temp.add(Theta_input_forcal.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double temp_radius = SplitRadiusWidth;
|
|
|
+ ArrayList<Integer> insideRowNumber_history = new ArrayList<>();
|
|
|
+ ArrayList<Integer> insideRowNumberlength = new ArrayList<>();
|
|
|
+ int insideRowNumberlength_history = 1;
|
|
|
+ while (true){
|
|
|
+ insideRowNumberlength.add(insideRowNumList(temp_radius,Row_input_temp).size());
|
|
|
+ int temp_size = insideRowNumberlength.size();
|
|
|
+// if(insideRowNumberlength.get(temp_size - 1) / insideRowNumberlength.get(temp_size - 2 ) < IncreasingRate){
|
|
|
+ if(insideRowNumberlength.get(temp_size - 1) / insideRowNumberlength_history < IncreasingRate){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ insideRowNumber_history = insideRowNumList(temp_radius,Row_input_temp);
|
|
|
+ temp_radius = temp_radius + SplitRadiusWidth;
|
|
|
+ insideRowNumberlength_history = insideRowNumberlength.get(temp_size - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<Double> Result_Row_temp = new ArrayList<>();
|
|
|
+ ArrayList<Double> Result_Theta_temp = new ArrayList<>();
|
|
|
+ for(int ii = 0 ; i < insideRowNumber_history.size() ; i++){
|
|
|
+ Result_Row_temp.add(Row_input_temp.get(insideRowNumber_history.get(i)));
|
|
|
+ Result_Theta_temp.add(Theta_input_temp.get(insideRowNumber_history.get(i)));
|
|
|
+ }
|
|
|
+ DataType<Double> Row_data = new DataType<>(Result_Row_temp);
|
|
|
+ DataType<Double> Theta_data = new DataType<>(Result_Theta_temp);
|
|
|
+ Result_Row.add(Row_data);
|
|
|
+ Result_Theta.add(Theta_data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public ArrayList<Integer> insideRowNumList(double Radius,ArrayList<Double>Row_input_temp){
|
|
|
+ ArrayList<Integer> insideRowNumber = new ArrayList<>();
|
|
|
+ for(int i = 0 ; i < Row_input_temp.size() ; i++){
|
|
|
+ if( Row_input_temp.get(i) < Radius ){
|
|
|
+ insideRowNumber.add(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return insideRowNumber;
|
|
|
+ }
|
|
|
}
|