Skip to content

Commit d5368e7

Browse files
Remove cgeom references
1 parent b6c854b commit d5368e7

File tree

5 files changed

+361
-361
lines changed

5 files changed

+361
-361
lines changed

xtrack/aperture/headers/base.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef float float_type;
1515
typedef struct {
1616
float_type x;
1717
float_type y;
18-
} G2DPoint;
18+
} Point2D;
1919

2020
typedef struct {
2121
float_type x;
@@ -37,17 +37,17 @@ typedef struct {
3737
} Pose;
3838

3939

40-
inline float_type geom2d_dot(G2DPoint, G2DPoint);
41-
inline float_type geom2d_cross(G2DPoint, G2DPoint);
42-
inline G2DPoint geom2d_sub(G2DPoint, G2DPoint);
43-
inline float_type geom2d_clamp(float_type t, float_type lo, float_type hi);
44-
inline float_type geom2d_points_distance(float_type x1, float_type y1, float_type x2, float_type y2);
45-
inline void geom2d_points_translate(float_type dx, float_type dy, G2DPoint* points, const int len_points);
40+
inline float_type point2d_dot(Point2D, Point2D);
41+
inline float_type point2d_cross(Point2D, Point2D);
42+
inline Point2D point2d_sub(Point2D, Point2D);
43+
inline float_type clamp_value(float_type t, float_type lo, float_type hi);
44+
inline float_type point2d_distance(float_type x1, float_type y1, float_type x2, float_type y2);
45+
inline void point2d_translate(float_type dx, float_type dy, Point2D* points, const int len_points);
4646

47-
static inline float_type geom2d_elliptic_E_adaptive(float_type a, float_type b, float_type eps, int depth, float_type m);
48-
static inline float_type geom2d_elliptic_E_numeric(float_type phi, float_type k);
49-
float_type geom2d_elliptic_E(float_type phi, float_type k);
50-
float_type geom2d_elliptic_E_complete(float_type k);
47+
static inline float_type elliptic_E_adaptive(float_type a, float_type b, float_type eps, int depth, float_type m);
48+
static inline float_type elliptic_E_numeric(float_type phi, float_type k);
49+
float_type elliptic_E(float_type phi, float_type k);
50+
float_type elliptic_E_complete(float_type k);
5151

5252
inline float_type sinc(float_type);
5353
inline void matrix_multiply_4x4(const float_type a[4][4], const float_type b[4][4], float_type result[4][4]);
@@ -59,31 +59,31 @@ inline Point3D point3d_add_scaled(const Point3D a, const Point3D v, const float_
5959
inline Point3D pose_apply_point(const Pose, const Point3D);
6060

6161

62-
inline float_type geom2d_dot(G2DPoint a, G2DPoint b)
62+
inline float_type point2d_dot(Point2D a, Point2D b)
6363
{
6464
return a.x*b.x + a.y*b.y;
6565
}
6666

6767

68-
inline float_type geom2d_cross(G2DPoint a, G2DPoint b)
68+
inline float_type point2d_cross(Point2D a, Point2D b)
6969
{
7070
return a.x*b.y - a.y*b.x;
7171
}
7272

7373

74-
inline G2DPoint geom2d_sub(G2DPoint a, G2DPoint b)
74+
inline Point2D point2d_sub(Point2D a, Point2D b)
7575
{
76-
G2DPoint r = {a.x-b.x, a.y-b.y};
76+
Point2D r = {a.x-b.x, a.y-b.y};
7777
return r;
7878
}
7979

8080

81-
inline float_type geom2d_clamp(float_type t, float_type lo, float_type hi) {
81+
inline float_type clamp_value(float_type t, float_type lo, float_type hi) {
8282
return (t < lo) ? lo : (t > hi) ? hi : t;
8383
}
8484

8585

86-
inline float_type geom2d_points_distance(float_type x1, float_type y1, float_type x2, float_type y2)
86+
inline float_type point2d_distance(float_type x1, float_type y1, float_type x2, float_type y2)
8787
/* Get the distance between two 2D points */
8888
{
8989
float_type dx = x2 - x1;
@@ -92,7 +92,7 @@ inline float_type geom2d_points_distance(float_type x1, float_type y1, float_typ
9292
}
9393

9494

95-
inline void geom2d_points_translate(float_type dx, float_type dy, G2DPoint* points, const int len_points)
95+
inline void point2d_translate(float_type dx, float_type dy, Point2D* points, const int len_points)
9696
/* Translate the `points` by (dx, dy)
9797
9898
Contract: len_points=len(points)
@@ -105,7 +105,7 @@ Contract: len_points=len(points)
105105
}
106106

107107

108-
static inline float_type geom2d_elliptic_E_adaptive(float_type a, float_type b, float_type eps, int depth, float_type m)
108+
static inline float_type elliptic_E_adaptive(float_type a, float_type b, float_type eps, int depth, float_type m)
109109
/* Incomplete elliptic integral of the second kind E(phi, k)
110110
Uses libm ellint_2/comp_ellint_2 when available (glibc),
111111
otherwise falls back to a small adaptive Simpson integrator.
@@ -125,42 +125,42 @@ static inline float_type geom2d_elliptic_E_adaptive(float_type a, float_type b,
125125
float_type Sright = (fc + 4.0 * f_right_c + fb) * (h / 2.0) / 6.0;
126126
if (depth <= 0 || fabs(Sleft + Sright - S) < 15.0 * eps)
127127
return Sleft + Sright + (Sleft + Sright - S) / 15.0;
128-
return geom2d_elliptic_E_adaptive(a, c, eps / 2.0, depth - 1, m) +
129-
geom2d_elliptic_E_adaptive(c, b, eps / 2.0, depth - 1, m);
128+
return elliptic_E_adaptive(a, c, eps / 2.0, depth - 1, m) +
129+
elliptic_E_adaptive(c, b, eps / 2.0, depth - 1, m);
130130
}
131131

132132

133-
static inline float_type geom2d_elliptic_E_numeric(float_type phi, float_type k)
133+
static inline float_type elliptic_E_numeric(float_type phi, float_type k)
134134
{
135135
float_type m = k * k;
136136
float_type sign = (phi >= 0.0) ? 1.0 : -1.0;
137137
float_type abs_phi = fabs(phi);
138138
float_type period = M_PI; /* integrand is periodic in pi */
139139
float_type half_pi = 0.5 * M_PI;
140-
float_type base_complete = geom2d_elliptic_E_adaptive(0.0, half_pi, 1e-10, 12, m);
140+
float_type base_complete = elliptic_E_adaptive(0.0, half_pi, 1e-10, 12, m);
141141
float_type per_value = 2.0 * base_complete; /* integral over one period */
142142
long periods = (long)(abs_phi / period);
143143
float_type remainder = abs_phi - periods * period;
144144
float_type total = periods * per_value;
145145
if (remainder > 0.0)
146-
total += geom2d_elliptic_E_adaptive(0.0, remainder, 1e-10, 12, m);
146+
total += elliptic_E_adaptive(0.0, remainder, 1e-10, 12, m);
147147
return sign * total;
148148
}
149149

150150

151-
float_type geom2d_elliptic_E(float_type phi, float_type k)
151+
float_type elliptic_E(float_type phi, float_type k)
152152
{
153153
if (k < 0.0 || k >= 1.0)
154154
return NAN;
155-
return geom2d_elliptic_E_numeric(phi, k);
155+
return elliptic_E_numeric(phi, k);
156156
}
157157

158158

159-
float_type geom2d_elliptic_E_complete(float_type k)
159+
float_type elliptic_E_complete(float_type k)
160160
{
161161
if (k < 0.0 || k >= 1.0)
162162
return NAN;
163-
return geom2d_elliptic_E_numeric(0.5 * M_PI, k);
163+
return elliptic_E_numeric(0.5 * M_PI, k);
164164
}
165165

166166

0 commit comments

Comments
 (0)