Skip to content

Documentation for debugging circle #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: NewSegments
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xcoll/geometry/c_init/bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ def x1(self):

@property
def s2(self):
return self.rC * self.cos_tC + self.l * self.cos_tb
return self.rC * self.cos_tC + self.l * abs(self.cos_tb)

@property
def x2(self):
return self.rC * self.sin_tC + self.l * self.sin_tb

@property
def s3(self):
return self.rC * self.cos_tC + self.l * self.cos_tb - self.w * self.sin_tb
return self.rC * self.cos_tC + self.l * abs(self.cos_tb) - self.w * self.sin_tb

@property
def x3(self):
Expand Down
19 changes: 10 additions & 9 deletions xcoll/geometry/segments/bezier.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ void BezierSegment_init_bounding_box(BezierSegment seg, BoundingBox box, double
xmin = MIN(x1, x2);
xmax = MAX(x1, x2);
}
BoundingBox_set_rC(box, sqrt(smin*smin + smax*smax)); // length of position vector to first vertex
BoundingBox_set_sin_tC(box, xmin / BoundingBox_get_rC(box)); // angle of position vector to first vertex
BoundingBox_set_cos_tC(box, smin / BoundingBox_get_rC(box));
BoundingBox_set_proj_l(box, smin); // projection of position vector on length: rC * (cos_t*cos_tC + sin_t*sin_tC)
BoundingBox_set_proj_w(box, xmin); // projection of position vector on width: rC * (cos_t*sin_tC - sin_t*cos_tC)
BoundingBox_set_l(box, smax - smin); // length of the box
BoundingBox_set_w(box, xmax - xmin); // width of the box
BoundingBox_set_sin_tb(box, 0); // orientation of the box (angle of length wrt horizontal)
BoundingBox_set_cos_tb(box, 1);
double rC = sqrt(smin*smin + smax*smax); // length of position vector to first vertex
double sin_tC = xmin / rC; // angle of position vector to first vertex
double cos_tC = smin / rC;
double proj_l = smin; // projection of position vector on length: rC * (cos_t*cos_tC + sin_t*sin_tC)
double proj_w = xmin; // projection of position vector on width: rC * (cos_t*sin_tC - sin_t*cos_tC)
double l = smax - smin; // length of the box
double w = xmax - xmin; // width of the box
double sin_tb = 0; // orientation of the box (angle of length wrt horizontal)
double cos_tb = 1;
BoundingBox_set_params(box, rC, sin_tC, cos_tC, l, w, sin_tb, cos_tb);
}


Expand Down
231 changes: 124 additions & 107 deletions xcoll/geometry/segments/circular.h

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions xcoll/geometry/segments/halfopen_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,23 @@ void HalfOpenLineSegment_init_bounding_box(HalfOpenLineSegment seg, BoundingBox
double s2 = HalfOpenLineSegment_func_s(seg, t2);
double x1 = HalfOpenLineSegment_func_x(seg, t1);
double x2 = HalfOpenLineSegment_func_x(seg, t2);
double sin_t = HalfOpenLineSegment_get_sin_t1(seg); // angle of the line wrt horizontal
double sin_t = HalfOpenLineSegment_get_sin_t1(seg); // angle of the line wrt horizontal
double cos_t = HalfOpenLineSegment_get_cos_t1(seg);
BoundingBox_set_l(box, sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1))); // length of the box
BoundingBox_set_w(box, 0.0); // width of the box
double w = BoundingBox_get_w(box);
BoundingBox_set_rC(box, sqrt(s1*s1 + x1*x1)); // length of the position vector to the first vertex
double l = sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1)); // length of the box
double w = 0.0; // width of the box
double rC = sqrt(s1*s1 + x1*x1); // length of the position vector to the first vertex
double rC = BoundingBox_get_rC(box);
BoundingBox_set_sin_tb(box, sin_t); // orientation of the box (angle of length wrt horizontal)
BoundingBox_set_cos_tb(box, cos_t);
if (BoundingBox_get_rC(box) == 0.){
BoundingBox_set_sin_tC(box, 0.0); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, 1.0);
double sin_tb = sin_t; // orientation of the box (angle of length wrt horizontal)
double cos_tb = cos_t;
double sin_tC, cos_tC; // angle of the position vector to the first vertex
if (rC == 0.){
sin_tC = 0.0; // angle of the position vector to the first vertex
cos_tC = 1.0;
} else {
BoundingBox_set_sin_tC(box, x1 / rC); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, s1 / rC);
sin_tC = x1 / rC; // angle of the position vector to the first vertex
cos_tC = s1 / rC;
}
BoundingBox_set_proj_l(box, rC * (cos_t*s1/rC + sin_t*x1/rC)); // projection of the position vector on length: rC * (cos_t*cos_tC + sin_t*sin_tC)
BoundingBox_set_proj_w(box, rC * (cos_t*x1/rC - sin_t*s1/rC)); // projection of position vector on width: rC * (cos_t*sin_tC - sin_t*cos_tC)
BoundingBox_set_params(box, rC, sin_tC, cos_tC, l, w, sin_t, cos_t);
}


Expand Down
26 changes: 12 additions & 14 deletions xcoll/geometry/segments/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,20 @@ void LineSegment_init_bounding_box(LineSegment seg, BoundingBox box, double t1,
double x2 = LineSegment_func_x(seg, t2);
double sin_t = (x2 - x1) / sqrt((x2 - x1)*(x2 - x1) + (s2 - s1)*(s2 - s1));
double cos_t = (s2 - s1) / sqrt((x2 - x1)*(x2 - x1) + (s2 - s1)*(s2 - s1));
BoundingBox_set_l(box, sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1))); // length of the box
BoundingBox_set_w(box, 0.); // width of the box cannot be 0 for (0,0)
BoundingBox_set_rC(box,sqrt(s1*s1 + x1*x1)); // length of the position vector to the first vertex
BoundingBox_set_sin_tb(box, sin_t); // orientation of the box (angle of length wrt horizontal)
BoundingBox_set_cos_tb(box, cos_t);
if (BoundingBox_get_rC(box) == 0.0){
BoundingBox_set_sin_tC(box, 0.0); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, 1.0);
double l = sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1)); // length of the box
double w = 0.; // width of the box cannot be 0 for (0,0)
double rC = sqrt(s1*s1 + x1*x1); // length of the position vector to the first vertex
double sin_tb = sin_t; // orientation of the box (angle of length wrt horizontal)
double cos_tb = cos_t;
double sin_tC, cos_tC; // angle of the position vector to the first vertex
if (rC == 0.0){
sin_tC = 0.0; // angle of the position vector to the first vertex
cos_tC = 1.0;
} else {
BoundingBox_set_sin_tC(box, x1 / BoundingBox_get_rC(box)); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, s1 / BoundingBox_get_rC(box));
sin_tC = x1 / rC; // angle of the position vector to the first vertex
cos_tC = s1 / rC;
}
double sin_tC = BoundingBox_get_sin_tC(box);
double cos_tC = BoundingBox_get_cos_tC(box);
BoundingBox_set_proj_l(box, BoundingBox_get_rC(box) * (cos_t*cos_tC + sin_t*sin_tC)); // projection of the position vector on length: rC * (cos_t*cos_tC + sin_t*sin_tC)
BoundingBox_set_proj_w(box, BoundingBox_get_rC(box) * (cos_t*sin_tC - sin_t*cos_tC)); // projection of position vector on width: rC * (cos_t*sin_tC - sin_t*cos_tC)
BoundingBox_set_params(box, rC, sin_tC, cos_tC, l, w, sin_t, cos_t)
}

// /*gpufun*/
Expand Down
14,865 changes: 115 additions & 14,750 deletions xcoll/geometry/test_geometry.ipynb

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions xcoll/geometry/trajectories/drift.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,20 @@ void DriftTrajectory_init_bounding_box(DriftTrajectory traj, BoundingBox box, do
double x2 = DriftTrajectory_func_x(traj, l2);
double sin_t0 = DriftTrajectory_get_sin_t0(traj);
double cos_t0 = DriftTrajectory_get_cos_t0(traj);
BoundingBox_set_l(box, sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1))); // length of the box
BoundingBox_set_w(box, 0.); // width of the box
BoundingBox_set_rC(box, sqrt(s1*s1 + x1*x1));
BoundingBox_set_sin_tb(box, sin_t0); // orientation of the box (angle of length wrt horizontal)
BoundingBox_set_cos_tb(box, cos_t0);
if (BoundingBox_get_rC(box) == 0.){
BoundingBox_set_sin_tC(box, 0.0); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, 1.0);
double l = sqrt((s2 - s1)*(s2 - s1) + (x2 - x1)*(x2 - x1)); // length of the box
double w = 0.; // width of the box
double rC = sqrt(s1*s1 + x1*x1);
double sin_tb = sin_t0; // orientation of the box (angle of length wrt horizontal)
double cos_tb = cos_t0;
double sin_tC, cos_tC; // angle of the position vector to the first vertex
if (rC == 0.){
double sin_tC = 0.0; // angle of the position vector to the first vertex
double cos_tC = 1.0;
} else {
BoundingBox_set_sin_tC(box, x1 / BoundingBox_get_rC(box)); // angle of the position vector to the first vertex
BoundingBox_set_cos_tC(box, s1 / BoundingBox_get_rC(box));
double sin_tC = x1 / rC; // angle of the position vector to the first vertex
double cos_tC = s1 / rC;
}
double sin_tC = BoundingBox_get_sin_tC(box);
double cos_tC = BoundingBox_get_cos_tC(box);
BoundingBox_set_proj_l(box, BoundingBox_get_rC(box) * (cos_t0*cos_tC + sin_t0*sin_tC)); // projection of the position vector on length: rC * (cos_t*cos_tC + sin_t*sin_tC)
BoundingBox_set_proj_w(box, BoundingBox_get_rC(box) * (cos_t0*sin_tC - sin_t0*cos_tC)); // projection of position vector on width: rC * (cos_t*sin_tC - sin_t*cos_tC)
BoundingBox_set_params(box, rC, sin_tC, cos_tC, l, w, sin_t0, cos_t0);
}


Expand Down