@@ -907,7 +907,7 @@ void s_curve::get_border_points(array_2d<double> &outpoints){
907
907
908
908
printf (" after (0,1), >2 fWorst %e -- %d\n " ,fWorst ,outpoints.get_rows ());
909
909
910
- double thetamin,thetamax,dtheta;
910
+ double thetamin,thetamax,dtheta,newtheta ;
911
911
912
912
for (ix=0 ;ix<2 ;ix++){
913
913
if (ix==1 ){
@@ -948,6 +948,14 @@ void s_curve::get_border_points(array_2d<double> &outpoints){
948
948
alpha.set (iy,centers.get_data (0 ,iy)+rr*sin (th));
949
949
alpha.set (ix,xth+rr*cos (th));
950
950
951
+ if (ix==0 ){
952
+ newtheta=find_theta_from_x (alpha.get_data (ix));
953
+ alpha.set (1 ,centers.get_data (0 ,1 )+trig_factor*newtheta*(cos (newtheta)-1.0 )/fabs (newtheta));
954
+ }
955
+ else {
956
+ newtheta=find_theta_from_y (alpha.get_data (ix));
957
+ alpha.set (0 ,centers.get_data (0 ,0 )+trig_factor*sin (newtheta));
958
+ }
951
959
952
960
for (i=0 ;i<dim;i++){
953
961
pt.set (i,0.0 );
@@ -1142,6 +1150,33 @@ double s_curve::distance_to_center(int ic, array_1d<double> &in_pt) {
1142
1150
return dd;
1143
1151
}
1144
1152
1153
+ double s_curve::find_theta_from_x (double x){
1154
+
1155
+ double dx=x-centers.get_data (0 ,0 );
1156
+
1157
+ double ratio=dx/trig_factor;
1158
+ if (ratio>1.0 )ratio=1.0 ;
1159
+ else if (ratio<-1.0 )ratio=-1.0 ;
1160
+
1161
+ double naive=asin (ratio);
1162
+
1163
+ return naive;
1164
+ }
1165
+
1166
+ double s_curve::find_theta_from_y (double y){
1167
+ double dy=y-centers.get_data (0 ,1 );
1168
+ double sgn;
1169
+ if (dy<0.0 )sgn=1.0 ;
1170
+ else sgn=-1.0 ;
1171
+
1172
+ double ratio=dy/trig_factor;
1173
+ if (ratio>2.0 )ratio=2.0 ;
1174
+ else if (ratio<-2.0 )ratio=-2.0 ;
1175
+
1176
+ double naive=acos (1.0 -fabs (ratio));
1177
+ return sgn*naive;
1178
+ }
1179
+
1145
1180
void s_curve::build_boundary (double br){
1146
1181
if (dice==NULL ){
1147
1182
death_knell (" you called build_boundary before making bases" );
@@ -1381,7 +1416,7 @@ void s_curve::build_boundary(double br){
1381
1416
1382
1417
printf (" after (0,1), >2 fWorst %e\n " ,fWorst );
1383
1418
1384
- double thetamin,thetamax,dtheta;
1419
+ double thetamin,thetamax,dtheta,newtheta ;
1385
1420
1386
1421
for (ix=0 ;ix<2 ;ix++){
1387
1422
if (ix==1 ){
@@ -1421,7 +1456,16 @@ void s_curve::build_boundary(double br){
1421
1456
1422
1457
alpha.set (iy,centers.get_data (0 ,iy)+rr*sin (th));
1423
1458
alpha.set (ix,xth+rr*cos (th));
1424
-
1459
+
1460
+ if (ix==0 ){
1461
+ newtheta=find_theta_from_x (alpha.get_data (ix));
1462
+ alpha.set (1 ,centers.get_data (0 ,1 )+trig_factor*newtheta*(cos (newtheta)-1.0 )/fabs (newtheta));
1463
+ }
1464
+ else {
1465
+ newtheta=find_theta_from_y (alpha.get_data (ix));
1466
+ alpha.set (0 ,centers.get_data (0 ,0 )+trig_factor*sin (newtheta));
1467
+ }
1468
+
1425
1469
1426
1470
for (i=0 ;i<dim;i++){
1427
1471
pt.set (i,0.0 );
@@ -1430,7 +1474,7 @@ void s_curve::build_boundary(double br){
1430
1474
}
1431
1475
}
1432
1476
chitest=(*this )(pt);
1433
- if (fabs (chitest-br)<5 .0 ){
1477
+ if (fabs (chitest-br)<1 .0 ){
1434
1478
err=fabs (chitest-br);
1435
1479
if (err>fWorst )fWorst =err;
1436
1480
add_to_boundary (alpha,ix,iy,chitest);
0 commit comments