working on circle points
"source": [
"def create_points_to_check(ball_bearing_diameter):\n",
" min_dist = 0.5\n",
- " diameters = np.arange(0, ball_bearing_diameter * 1.2, min_dist)\n",
+ " distances = np.arange(0, ball_bearing_diameter * 1.2, min_dist)\n",
"\n",
- " def points_to_check(bb_centre):\n",
" x = []\n",
" y = []\n",
- " for i, diameter in enumerate(diameters):\n",
- " new_x, new_y = pymedphys._gamma.implementation.shell.calculate_coordinates_shell_2d(diameter, min_dist)\n",
- " x.append(new_x + bb_centre[0])\n",
- " y.append(new_y + bb_centre[1])\n",
+ " dist = []\n",
+ " \n",
+ " for _, distance in enumerate(distances):\n",
+ " new_x, new_y = pymedphys._gamma.implementation.shell.calculate_coordinates_shell_2d(distance, min_dist)\n",
+ " x.append(new_x)\n",
+ " y.append(new_y)\n",
+ " dist.append(distance * np.ones_like(new_x))\n",
"\n",
" x = np.concatenate(x)\n",
" y = np.concatenate(y)\n",
+ " dist = np.concatenate(dist)\n",
+ " \n",
+ " def points_to_check(bb_centre):\n",
+ " x_shifted = x + bb_centre[0]\n",
+ " y_shifted = y + bb_centre[1]\n",
" \n",
- " return x, y\n",
+ " return x_shifted, y_shifted\n",
" \n",
- " return points_to_check\n",
+ " return points_to_check, dist\n",
"\n",
"\n",
- "points_to_check = create_points_to_check(8)\n",
- "# points_to_check([1.46, -1.9])\n",
- "plt.scatter(*points_to_check([1.46, -1.9]), s=3)\n",
+ "points_to_check, dist = create_points_to_check(8)\n",
+ "x, y = points_to_check([1.46, -1.9])\n",
+ "plt.scatter(x, y, s=3)\n",
"plt.axis('equal')"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "dist_mask = (np.unique(dist)[:, None] == dist[None, :])\n",
+ "\n",
+ "x[dist_mask[1]]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "dist[None, :] == dist[:, None]"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
"source": [
"def create_bb_to_minimise(field, ball_bearing_diameter):\n",
" \n",
- " points_to_check = create_points_to_check(ball_bearing_diameter)\n",
+ " points_to_check, dist = create_points_to_check(ball_bearing_diameter)\n",
" \n",
" def to_minimise(centre):\n",
- " "
+ " x, y = points_to_check(centre)\n",
+ " \n",
+ " field(x, y)"
]
},
{
