Exemplo n.º 1
0
RFunction::coord_type 
function_algebra_hermite::derive(const RFunction::coord_type& x,
				 const RFunction::coord_type& h) const
{
  double t = (x[1]-a)/(b-a);
  if (t <= 0.0) return coord_type(0.0);
  else if (t<= 1.0) return coord_type(h*(6.0*t*(1.0-t)/(b-a)) );
  else return coord_type(0.0);
}
Exemplo n.º 2
0
	KTL_INLINE void SpriteCoord::setCenter(tTVInteger v1, tTVInteger v2) {
		instance_->setCenter(
			coord_type(
				boost::numeric_cast<NativeSpriteCoord::coord_element_type>(v1),
				boost::numeric_cast<NativeSpriteCoord::coord_element_type>(v2)
				)
			);
	}
Exemplo n.º 3
0
function_algebra_impl::coord_type 
function_algebra_polynomial1D::eval(const coord_type& x) const
{
  int n= degree();
  double bk=coeffs[n+1],x1=x[1];
  for(int k=1;k<=n;k++) {
    bk = x1*bk +coeffs[n+1-k];
  }
  return coord_type(bk);
}
Exemplo n.º 4
0
function_algebra_impl::coord_type 
function_algebra_polynomial1D::derive(const coord_type& x, const coord_type& h) const
{
  int n= degree();
  double bk=n*coeffs[n+1],x1=x[1];
  for(int k=1;k<=n-1;k++) {
    bk = x1*bk +(n-k)*coeffs[n+1-k];
  }
  return coord_type(bk*h[1]);
}
Exemplo n.º 5
0
    //------------------------------------------------------------------------
    void gen_stroke::calc_miter(const vertex_dist& v0, 
                                const vertex_dist& v1, 
                                const vertex_dist& v2,
                                double dx1, double dy1, 
                                double dx2, double dy2)
    {
        double xi = v1.x;
        double yi = v1.y;
        if(!calc_intersection(v0.x + dx1, v0.y - dy1,
                              v1.x + dx1, v1.y - dy1,
                              v1.x + dx2, v1.y - dy2,
                              v2.x + dx2, v2.y - dy2,
                              &xi, &yi))
        {
            m_out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
        }
        else
        {
            double d1 = calc_distance(v1.x, v1.y, xi, yi);
            double lim = m_width * m_miter_limit;
            if(d1 > lim)
            {
                d1  = lim / d1;
                double x1 = v1.x + dx1;
                double y1 = v1.y - dy1;
                double x2 = v1.x + dx2;
                double y2 = v1.y - dy2;

                x1 += (xi - x1) * d1;
                y1 += (yi - y1) * d1;
                x2 += (xi - x2) * d1;
                y2 += (yi - y2) * d1;
                m_out_vertices.add(coord_type(x1, y1));
                m_out_vertices.add(coord_type(x2, y2));
            }
            else
            {
                m_out_vertices.add(coord_type(xi, yi));
            }
        }
    }
Exemplo n.º 6
0
 //------------------------------------------------------------------------
 void vcgen_markers_term::add_vertex(double x, double y, unsigned cmd)
 {
     if(is_move_to(cmd))
     {
         if(m_markers.size() & 1)
         {
             // Initial state, the first coordinate was added.
             // If two of more calls of start_vertex() occures
             // we just modify the last one.
             m_markers.modify_last(coord_type(x, y));
         }
         else
         {
             m_markers.add(coord_type(x, y));
         }
     }
     else
     {
         if(is_vertex(cmd))
         {
             if(m_markers.size() & 1)
             {
                 // Initial state, the first coordinate was added.
                 // Add three more points, 0,1,1,0
                 m_markers.add(coord_type(x, y));
                 m_markers.add(m_markers[m_markers.size() - 1]);
                 m_markers.add(m_markers[m_markers.size() - 3]);
             }
             else
             {
                 if(m_markers.size())
                 {
                     // Replace two last points: 0,1,1,0 -> 0,1,2,1
                     m_markers[m_markers.size() - 1] = m_markers[m_markers.size() - 2];
                     m_markers[m_markers.size() - 2] = coord_type(x, y);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
    //------------------------------------------------------------------------
    void gen_stroke::calc_join(const vertex_dist& v0, 
                               const vertex_dist& v1, 
                               const vertex_dist& v2,
                               double len1, double len2)
    {
        double dx1, dy1, dx2, dy2;

        dx1 = m_width * (v1.y - v0.y) / len1;
        dy1 = m_width * (v1.x - v0.x) / len1;

        dx2 = m_width * (v2.y - v1.y) / len2;
        dy2 = m_width * (v2.x - v1.x) / len2;

        m_out_vertices.remove_all();
        if(m_line_join == miter_join)
        {
            calc_miter(v0, v1, v2, dx1, dy1, dx2, dy2);
        }
        else
        {
            if(calc_point_location(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y) > 0.0)
            {
                calc_miter(v0, v1, v2, dx1, dy1, dx2, dy2);
            }
            else
            {
                if(m_line_join == round_join)
                {
                    calc_arc(v1.x, v1.y, dx1, -dy1, dx2, -dy2);
                }
                else
                {
                    m_out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
                    m_out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2));
                }
            }
        }
    }
Exemplo n.º 8
0
    //------------------------------------------------------------------------
    void gen_stroke::calc_arc(double x,   double y, 
                              double dx1, double dy1, 
                              double dx2, double dy2)
    {
        double a1 = atan2(dy1, dx1);
        double a2 = atan2(dy2, dx2);
        double da = a1 - a2;

        if(fabs(da) < gen_stroke_theta)
        {
            m_out_vertices.add(coord_type(x + dx1, y + dy1));
            m_out_vertices.add(coord_type(x + dx2, y + dy2));
            return;
        }

        bool ccw = da > 0.0 && da < pi;

        da = fabs(1.0 / (m_width * m_approx_scale));
        if(!ccw)
        {
            if(a1 > a2) a2 += 2 * pi;
            while(a1 < a2)
            {
                m_out_vertices.add(coord_type(x + cos(a1) * m_width, y + sin(a1) * m_width));
                a1 += da;
            }
        }
        else
        {
            if(a1 < a2) a2 -= 2 * pi;
            while(a1 > a2)
            {
                m_out_vertices.add(coord_type(x + cos(a1) * m_width, y + sin(a1) * m_width));
                a1 -= da;
            }
        }
        m_out_vertices.add(coord_type(x + dx2, y + dy2));
    }
Exemplo n.º 9
0
    //------------------------------------------------------------------------
    void gen_stroke::calc_cap(const vertex_dist& v0, 
                              const vertex_dist& v1, 
                              double len)
    {
        m_out_vertices.remove_all();

        double dx1 = m_width * (v1.y - v0.y) / len;
        double dy1 = m_width * (v1.x - v0.x) / len;
        double dx2 = 0;
        double dy2 = 0;


        if(m_line_cap == square_cap)
        {
            dx2 = dy1;
            dy2 = dx1;
        }

        if(m_line_cap == round_cap)
        {
            double a1 = atan2(dy1, -dx1);
            double a2 = a1 + pi;
            double da = fabs(1.0 / (m_width * m_approx_scale));
            while(a1 < a2)
            {
                m_out_vertices.add(coord_type(v0.x + cos(a1) * m_width, 
                                              v0.y + sin(a1) * m_width));
                a1 += da;
            }
            m_out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1));
        }
        else
        {
            m_out_vertices.add(coord_type(v0.x - dx1 - dx2, v0.y + dy1 - dy2));
            m_out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2));
        }
    }
Exemplo n.º 10
0
 virtual coord_type eval(const coord_type& x) const { return coord_type(x*x);}
Exemplo n.º 11
0
 coord_type derive(const coord_type& x,const coord_type& h) const {return coord_type((2.0*(x*h)));}
Exemplo n.º 12
0
 coord_type derive(const coord_type& x,const coord_type& h) const {
   return coord_type(h[1] *0.5/(eval(coord_type(x[1])))[1]);}
Exemplo n.º 13
0
 virtual coord_type eval(const coord_type& x) const { return coord_type(atan2(x[2],x[1]));}
Exemplo n.º 14
0
 coord_type derive(const coord_type& x,const coord_type& h) const 
 {
   double n= x.length2(); 
   return coord_type(coord_type(-x[2]/n,x[1]/n)*h);
 }
Exemplo n.º 15
0
rect screen::bounds( bool active ) const
{
	return rect( coord_type( 0 ), coord_type( 0 ), coord_type( 1024 ), coord_type( 720 ) );
}
Exemplo n.º 16
0
 coord_type derive(const coord_type& x,const coord_type& h) const {
   return coord_type(1.0/(1.0+x*x)*h[1]);
 }
Exemplo n.º 17
0
 virtual coord_type eval(const coord_type& x) const {return coord_type((x-m).length() - r);}
Exemplo n.º 18
0
 coord_type derive(const coord_type& x, const coord_type& h) const { return coord_type(((x-m)*h)/(x-m).length());}
Exemplo n.º 19
0
 coord_type derive(const coord_type& /*x*/, const coord_type& h) const { return coord_type(h*normal);}
Exemplo n.º 20
0
 coord_type  derive(const coord_type& /*x*/, const coord_type& /*h*/) const { return coord_type(0.0);}
Exemplo n.º 21
0
 virtual coord_type eval(const coord_type& x) const 
  { return coord_type(ap::squared_norm_2(x)); }
Exemplo n.º 22
0
 coord_type derive(const coord_type& x,const coord_type& h) const {return coord_type(-sin(x[1])*h[1]);}
Exemplo n.º 23
0
 coord_type derive(const coord_type& /*x*/, const coord_type& h) const { return coord_type(h[i]);}
Exemplo n.º 24
0
 virtual coord_type eval(const coord_type& x) const { return coord_type(cos(x[1]));}
Exemplo n.º 25
0
 vertex(vertex<T2,2> const& rhs)
     : x(coord_type(rhs.x)),
       y(coord_type(rhs.y)),
       cmd(rhs.cmd) {}
Exemplo n.º 26
0
 virtual coord_type eval(const coord_type& x) const { return coord_type(x*normal-dist);}
Exemplo n.º 27
0
 virtual coord_type eval(const coord_type& x) const
 { return coord_type(hermite(a,b,x[1]));}