本文整理汇总了C++中Piecewise::domain方法的典型用法代码示例。如果您正苦于以下问题:C++ Piecewise::domain方法的具体用法?C++ Piecewise::domain怎么用?C++ Piecewise::domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piecewise
的用法示例。
在下文中一共展示了Piecewise::domain方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(cairo_t *cr, int t) {
if(t - last_time > path.domain().max()) add_section(random_d2());
if(t - last_time - length > path.cuts[1]) {
Piecewise<D2<SBasis> > new_path;
new_path.push_cut(0);
for(unsigned i = 1; i < path.size(); i++) {
new_path.push(path[i], path.cuts[i+1] - path.cuts[1]);
}
last_time = t - length;
path = new_path;
}
cairo_set_source_rgb(cr, red, green, blue);
Piecewise<D2<SBasis> > port = portion(path, std::max(t - last_time - length, 0.), t - last_time);
cairo_pw_d2_sb(cr, port);
cairo_stroke(cr);
double d = 4;
cairo_set_dash(cr, &d, 1, 0);
for(unsigned i = 1; i < path.size(); i++) {
if(path[i].at0() != path[i-1].at1()) {
draw_line_seg(cr, path[i].at0(), path[i-1].at1());
}
}
cairo_stroke(cr);
cairo_set_dash(cr, &d, 0, 0);
cairo_set_source_rgb(cr, 0., 0., 1.);
dot_plot(cr, path, std::max(t - last_time - length, 0.), t - last_time);
}
示例2: add_section
void add_section(const D2<SBasis> x) {
Piecewise<D2<SBasis> > new_path(path);
D2<SBasis> seg(x);
seg[0][0][0] = path.segs.back()[0][0][1];
seg[1][0][0] = path.segs.back()[1][0][1];
new_path.push(seg, path.domain().max()+1);
path = arc_length_parametrization(new_path);
}
示例3: plot_graph
static void plot_graph(cairo_t *cr, Piecewise<SBasis> const &f,
double x_scale=300,
double y_scale=100){
//double dt=(M[0].cuts.back()-M[0].cuts.front())/space;
D2<Piecewise<SBasis> > g;
g[X] = Piecewise<SBasis>( SBasis(Linear(100+f.cuts.front()*x_scale,
100+f.cuts.back()*x_scale)));
g[X].setDomain(f.domain());
g[Y] = -f*y_scale+400;
cairo_d2_pw_sb(cr, g);
}
示例4: sqrt
/** Compute the sqrt of a function.
\param f function
*/
Piecewise<SBasis> sqrt(Piecewise<SBasis> const &f, double tol, int order){
Piecewise<SBasis> result;
Piecewise<SBasis> zero = Piecewise<SBasis>(Linear(tol*tol));
zero.setDomain(f.domain());
Piecewise<SBasis> ff=max(f,zero);
for (unsigned i=0; i<ff.size(); i++){
Piecewise<SBasis> sqrtfi = sqrt_internal(ff.segs[i],tol,order);
sqrtfi.setDomain(Interval(ff.cuts[i],ff.cuts[i+1]));
result.concat(sqrtfi);
}
return result;
}
示例5: tele
void tele(int t) {
Piecewise<D2<SBasis> > new_path(portion(path, 0, t - last_time));
new_path.push(random_d2(), path.domain().max()+1);
path = arc_length_parametrization(new_path);
}
示例6:
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
using namespace Geom;
Piecewise<D2<SBasis> > output;
std::vector<Piecewise<D2<SBasis> > > pre_output;
double prop_scale = 1.0;
D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(pwd2_in);
Piecewise<SBasis> x0 = false /*vertical_pattern.get_value()*/ ? Piecewise<SBasis>(patternd2[1]) : Piecewise<SBasis>(patternd2[0]);
Piecewise<SBasis> y0 = false /*vertical_pattern.get_value()*/ ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]);
OptInterval pattBndsX = bounds_exact(x0);
OptInterval pattBndsY = bounds_exact(y0);
if ( !pattBndsX || !pattBndsY) {
return pwd2_in;
}
x0 -= pattBndsX->min();
y0 -= pattBndsY->middle();
double xspace = 0;//spacing;
double noffset = 0;//normal_offset;
double toffset = 0;//tang_offset;
if (false /*prop_units.get_value()*/){
xspace *= pattBndsX->extent();
noffset *= pattBndsY->extent();
toffset *= pattBndsX->extent();
}
y0+=noffset;
output = pwd2_in;
for (int i = 0; i < iterations; ++i) {
std::vector<Piecewise<D2<SBasis> > > skeleton = split_at_discontinuities(output);
output.clear();
for (unsigned idx = 0; idx < skeleton.size(); idx++){
Piecewise<D2<SBasis> > path_i = skeleton[idx];
Piecewise<SBasis> x = x0;
Piecewise<SBasis> y = y0;
Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(path_i,2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton));
n = force_continuity(remove_short_cuts(n,.1));
double scaling = 1;
scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent();
// TODO investigate why pattWidth is not being used:
double pattWidth = pattBndsX->extent() * scaling;
if (scaling != 1.0) {
x*=scaling;
}
if ( true /*scale_y_rel.get_value()*/ ) {
y*=(scaling*prop_scale);
} else {
if (prop_scale != 1.0) y *= prop_scale;
}
x += toffset;
output.concat(compose(uskeleton,x)+y*compose(n,x));
}
}
return output;
}