Skip to content

Commit f962c4f

Browse files
committed
cleaned up control file plotting code; no more complete circles at caps
1 parent bcc2480 commit f962c4f

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

chisq.cpp

+48-4
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void s_curve::get_border_points(array_2d<double> &outpoints){
907907

908908
printf("after (0,1), >2 fWorst %e -- %d\n",fWorst,outpoints.get_rows());
909909

910-
double thetamin,thetamax,dtheta;
910+
double thetamin,thetamax,dtheta,newtheta;
911911

912912
for(ix=0;ix<2;ix++){
913913
if(ix==1){
@@ -948,6 +948,14 @@ void s_curve::get_border_points(array_2d<double> &outpoints){
948948
alpha.set(iy,centers.get_data(0,iy)+rr*sin(th));
949949
alpha.set(ix,xth+rr*cos(th));
950950

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+
}
951959

952960
for(i=0;i<dim;i++){
953961
pt.set(i,0.0);
@@ -1142,6 +1150,33 @@ double s_curve::distance_to_center(int ic, array_1d<double> &in_pt) {
11421150
return dd;
11431151
}
11441152

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+
11451180
void s_curve::build_boundary(double br){
11461181
if(dice==NULL){
11471182
death_knell("you called build_boundary before making bases");
@@ -1381,7 +1416,7 @@ void s_curve::build_boundary(double br){
13811416

13821417
printf("after (0,1), >2 fWorst %e\n",fWorst);
13831418

1384-
double thetamin,thetamax,dtheta;
1419+
double thetamin,thetamax,dtheta,newtheta;
13851420

13861421
for(ix=0;ix<2;ix++){
13871422
if(ix==1){
@@ -1421,7 +1456,16 @@ void s_curve::build_boundary(double br){
14211456

14221457
alpha.set(iy,centers.get_data(0,iy)+rr*sin(th));
14231458
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+
14251469

14261470
for(i=0;i<dim;i++){
14271471
pt.set(i,0.0);
@@ -1430,7 +1474,7 @@ void s_curve::build_boundary(double br){
14301474
}
14311475
}
14321476
chitest=(*this)(pt);
1433-
if(fabs(chitest-br)<5.0){
1477+
if(fabs(chitest-br)<1.0){
14341478
err=fabs(chitest-br);
14351479
if(err>fWorst)fWorst=err;
14361480
add_to_boundary(alpha,ix,iy,chitest);

chisq.h

+3
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ class s_curve : public chisquared{
324324

325325
private:
326326
double trig_factor;
327+
328+
double find_theta_from_x(double);
329+
double find_theta_from_y(double);
327330

328331
public:
329332
~s_curve();

0 commit comments

Comments
 (0)