00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "wall.hh"
00011
00012
00013
00014
00015 bool wall_sphere::point_inside(fpoint x,fpoint y,fpoint z) {
00016 return (x-xc)*(x-xc)+(y-yc)*(y-yc)+(z-zc)*(z-zc)<rc*rc;
00017 }
00018
00019
00020
00021
00022
00023
00024
00025
00026 template<class n_option>
00027 inline bool wall_sphere::cut_cell_base(voronoicell_base<n_option> &c,fpoint x,fpoint y,fpoint z) {
00028 fpoint xd=x-xc,yd=y-yc,zd=z-zc,dq;
00029 dq=xd*xd+yd*yd+zd*zd;
00030 if (dq>1e-5) {
00031 dq=2*(sqrt(dq)*rc-dq);
00032 return c.nplane(xd,yd,zd,dq,w_id);
00033 }
00034 return true;
00035 }
00036
00037
00038
00039
00040 bool wall_plane::point_inside(fpoint x,fpoint y,fpoint z) {
00041 return x*xc+y*yc+z*zc<ac;
00042 }
00043
00044
00045
00046
00047
00048 template<class n_option>
00049 inline bool wall_plane::cut_cell_base(voronoicell_base<n_option> &c,fpoint x,fpoint y,fpoint z) {
00050 fpoint dq=2*(ac-x*xc-y*yc-z*zc);
00051 return c.nplane(xc,yc,zc,dq,w_id);
00052 }
00053
00054
00055
00056
00057 bool wall_cylinder::point_inside(fpoint x,fpoint y,fpoint z) {
00058 fpoint xd=x-xc,yd=y-yc,zd=z-zc;
00059 fpoint pa=(xd*xa+yd*ya+zd*za)*asi;
00060 xd-=xa*pa;yd-=ya*pa;zd-=za*pa;
00061 return xd*xd+yd*yd+zd*zd<rc*rc;
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 template<class n_option>
00073 inline bool wall_cylinder::cut_cell_base(voronoicell_base<n_option> &c,fpoint x,fpoint y,fpoint z) {
00074 fpoint xd=x-xc,yd=y-yc,zd=z-zc;
00075 fpoint pa=(xd*xa+yd*ya+zd*za)*asi;
00076 xd-=xa*pa;yd-=ya*pa;zd-=za*pa;
00077 pa=xd*xd+yd*yd+zd*zd;
00078 if(pa>1e-5) {
00079 pa=2*(sqrt(pa)*rc-pa);
00080 return c.nplane(xd,yd,zd,pa,w_id);
00081 }
00082 return true;
00083 }
00084
00085
00086
00087
00088 bool wall_cone::point_inside(fpoint x,fpoint y,fpoint z) {
00089 fpoint xd=x-xc,yd=y-yc,zd=z-zc;
00090 fpoint pa=(xd*xa+yd*ya+zd*za)*asi;
00091 xd-=xa*pa;yd-=ya*pa;zd-=za*pa;
00092 pa*=gra;
00093 if (pa<0) return false;
00094 pa*=pa;
00095 return xd*xd+yd*yd+zd*zd<pa;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 template<class n_option>
00107 inline bool wall_cone::cut_cell_base(voronoicell_base<n_option> &c,fpoint x,fpoint y,fpoint z) {
00108 fpoint xd=x-xc,yd=y-yc,zd=z-zc;
00109 fpoint xf,yf,zf,imoda;
00110 fpoint pa=(xd*xa+yd*ya+zd*za)*asi;
00111 xd-=xa*pa;yd-=ya*pa;zd-=za*pa;
00112 pa=xd*xd+yd*yd+zd*zd;
00113 if(pa>1e-5) {
00114 pa=1/sqrt(pa);
00115 imoda=sqrt(asi);
00116 xf=-sang*imoda*xa+cang*pa*xd;
00117 yf=-sang*imoda*ya+cang*pa*yd;
00118 zf=-sang*imoda*za+cang*pa*zd;
00119 pa=2*(xf*(xc-x)+yf*(yc-y)+zf*(zc-z));
00120 return c.nplane(xf,yf,zf,pa,w_id);
00121 }
00122 return true;
00123 }