Esempio n. 1
0
    void make_unique(points_t& pts)
    {
	    std::sort(pts.begin(),pts.end(),less_point_pr());
	    pts.erase(
		    std::unique(pts.begin(),pts.end()),
		    pts.end());
    }
Esempio n. 2
0
	void field_t::get_empty_around(const point& c,points_t& res,int bound_size) const
	{
		res.resize(0);
		for(int y=c.y-bound_size;y<=c.y+bound_size;y++)
		for(int x=c.x-bound_size;x<=c.x+bound_size;x++)
		{
			point p(x,y);
			if(at(p)==st_empty)
				res.push_back(p);
		}

		std::sort(res.begin(),res.end(),less_point_pr());
		res.erase(std::unique(res.begin(),res.end()),res.end());
	}
Esempio n. 3
0
            inline void polynomial()
            {
                const size_t np = points.size();
                const size_t m  = min_of<size_t>(degree+1,np);

                //______________________________________________________________
                //
                // initialize parameters
                //______________________________________________________________
                mu.make(m);
                mu.ldz();
                coeff.make(m,0);
                typename points_t::iterator pp = points.begin();


                //______________________________________________________________
                //
                // accumulate
                //______________________________________________________________
                for(size_t i=np;i>0;--i,++pp)
                {
                    const point_t p = *pp;
                    for(size_t j=m,jm=m-1;j>0;--j,--jm)
                    {
                        const T   xjm  = ipower<T>(p.x,jm);
                        array<T> &mu_j = mu[j];

                        coeff[j]   += xjm * p.y;
                        for(size_t k=j,km=jm;k>0;--k,--km)
                        {
                            const T xkm = ipower<T>(p.x,km);
                            mu_j[k] += xkm*xjm;
                        }
                    }
                }

                //______________________________________________________________
                //
                // symetrisation
                //______________________________________________________________
                for(size_t j=m;j>0;--j)
                {
                    array<T> &mu_j = mu[j];
                    for(size_t k=j+1;k<=m;++k)
                    {
                        mu_j[k] = mu[k][j];
                    }
                }

                //______________________________________________________________
                //
                // compute parameters
                //______________________________________________________________
                if(!LU<T>::build(mu))
                {
                    throw libc::exception( EINVAL, "invalid data to smooth" );
                }
                LU<T>::solve(mu,coeff);
            }
Esempio n. 4
0
	void field_t::get_empty_around(points_t& res,int bound_size) const
	{
		res.resize(0);
		for(unsigned i=0;i<steps.size();i++)
		{
			const step_t& st=steps[i];
			for(int y=st.y-bound_size;y<=st.y+bound_size;y++)
			for(int x=st.x-bound_size;x<=st.x+bound_size;x++)
			{
				point p(x,y);
				if(at(p)==st_empty)
					res.push_back(p);
			}
		}

		std::sort(res.begin(),res.end(),less_point_pr());
		res.erase(std::unique(res.begin(),res.end()),res.end());
	}