1 // Voro++, a 3D cell-based Voronoi library
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
8 * \brief Function implementations for the 2D derived wall classes. */
14 /** Tests to see whether a point is inside the sphere wall object.
15 * \param[in,out] (x,y,z) the vector to test.
16 * \return True if the point is inside, false if the point is outside. */
17 bool wall_circle_2d::point_inside(double x
,double y
) {
18 return (x
-xc
)*(x
-xc
)+(y
-yc
)*(y
-yc
)<rc
*rc
;
21 /** Cuts a cell by the circular wall object. The circular wall is approximated
22 * by a single plane applied at the point on the sphere which is closest to the
23 * center of the cell. This works well for particle arrangements that are
24 * packed against the wall, but loses accuracy for sparse particle
26 * \param[in,out] c the Voronoi cell to be cut.
27 * \param[in] (x,y) the location of the Voronoi cell.
28 * \return True if the cell still exists, false if the cell is deleted. */
29 template<class v_cell_2d
>
30 bool wall_circle_2d::cut_cell_base(v_cell_2d
&c
,double x
,double y
) {
31 double xd
=x
-xc
,yd
=y
-yc
,dq
;
34 dq
=2*(sqrt(dq
)*rc
-dq
);
35 return c
.nplane(xd
,yd
,dq
,w_id
);
40 /** Tests to see whether a point is inside the plane wall object.
41 * \param[in] (x,y,z) the vector to test.
42 * \return True if the point is inside, false if the point is outside. */
43 bool wall_plane_2d::point_inside(double x
,double y
) {
47 /** Cuts a cell by the plane wall object.
48 * \param[in,out] c the Voronoi cell to be cut.
49 * \param[in] (x,y) the location of the Voronoi cell.
50 * \return True if the cell still exists, false if the cell is deleted. */
51 template<class v_cell_2d
>
52 bool wall_plane_2d::cut_cell_base(v_cell_2d
&c
,double x
,double y
) {
53 double dq
=2*(ac
-x
*xc
-y
*yc
);
54 return c
.nplane(xc
,yc
,dq
,w_id
);
57 // Explicit instantiation
58 template bool wall_circle_2d::cut_cell_base(voronoicell_2d
&c
,double x
,double y
);
59 template bool wall_circle_2d::cut_cell_base(voronoicell_neighbor_2d
&c
,double x
,double y
);
60 template bool wall_plane_2d::cut_cell_base(voronoicell_2d
&c
,double x
,double y
);
61 template bool wall_plane_2d::cut_cell_base(voronoicell_neighbor_2d
&c
,double x
,double y
);