本文整理匯總了C++中Interval::contains方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::contains方法的具體用法?C++ Interval::contains怎麽用?C++ Interval::contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::contains方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: intersectXRect
bool IntersectShape::intersectXRect(const Ray &ray, const double &x, const Interval &yrange, const Interval &zrange, double &t)
{
if (IntersectShape::intersectXPlane(ray, x, t))
return yrange.contains(ray.p.y + t * ray.d.y) &&
zrange.contains(ray.p.z + t * ray.d.z);
else
return false;
}
示例2: intersectZRect
bool IntersectShape::intersectZRect(const Ray &ray, const double &z, const Interval &xrange, const Interval &yrange, double &t)
{
if (IntersectShape::intersectZPlane(ray, z, t))
return yrange.contains(ray.p.y + t * ray.d.y) &&
xrange.contains(ray.p.x + t * ray.d.x);
else
return false;
}
示例3: intersectYRect
bool IntersectShape::intersectYRect(const Ray &ray, const double &y, const Interval &xrange, const Interval &zrange, double &t)
{
if (IntersectShape::intersectYPlane(ray, y, t))
return xrange.contains(ray.p.x + t * ray.d.x) &&
zrange.contains(ray.p.z + t * ray.d.z);
else
return false;
}
示例4: insert
void TreeNode::insert(Interval i){
if(i.contains(center)){
left_end.push_back(i.a);
right_end.push_back(i.b);
return;
}
if(i.b < center){
//interval is left to center
if(!left)
left = new TreeNode(i.middle());
left->insert(i);
}
else{
//interval is right to center
if(!right)
right = new TreeNode(i.middle());
right->insert(i);
}
}
示例5: draw
virtual void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
cairo_set_source_rgba (cr, 0., 0., 0, 1);
cairo_set_line_width (cr, 1);
if(0) {
Path path;
path = Path(path_handles.pts[0]);
D2<SBasis> c = handles_to_sbasis(path_handles.pts.begin(), 2);
path.append(c);
cairo_save(cr);
cairo_path(cr, path);
cairo_set_source_rgba (cr, 0., 1., 0, 0.3);
cairo_set_line_width (cr, 3);
cairo_stroke(cr);
cairo_restore(cr);
//double w = exp(sliders[0].value());
}
Point A = path_handles.pts[0];
Point B = path_handles.pts[1];
Point C = path_handles.pts[2];
if(1) {
QuadraticBezier qb(A, B, C);
//double abt = qb.nearestTime(oncurve.pos);
//oncurve.pos = qb.pointAt(abt);
RatQuad rq = RatQuad::fromPointsTangents(A, B-A, oncurve.pos, C, B -C); //( A, B, C, w);
cairo_save(cr);
cairo_set_source_rgba (cr, 0., 0., 0, 1);
cairo_set_line_width (cr, 1);
draw_ratquad(cr, rq);
//cairo_d2_sb(cr, rq.hermite());
cairo_stroke(cr);
cairo_restore(cr);
}
if(0) {
RatQuad rq = RatQuad::circularArc(A, B, C);
cairo_save(cr);
cairo_set_source_rgba (cr, 0., 0., 0, 1);
cairo_set_line_width (cr, 1);
RatQuad a, b;
rq.split(a,b);
cairo_curve(cr, a.toCubic());
cairo_curve(cr, b.toCubic());
cairo_stroke(cr);
cairo_restore(cr);
}
Rect screen_rect(Interval(10, width-10), Interval(10, height-10));
Line cutLine(cutting_plane.pts[0], cutting_plane.pts[1]);
//double dist;
//Point norm = cutLine.normalAndDist(dist);
const unsigned N = 3;
xAx sources[N] = {
xAx::fromPoint(A)*(exp(-sliders[0].value())),
xAx::fromPoint(B)*(exp(-sliders[1].value())),
xAx::fromPoint(C)*(exp(-sliders[2].value()))
//xAx::fromLine(Line(A, oncurve.pos))
};
for(unsigned i = 0; i < N; i++) {
//*notify << sources[i] << "\n";
}
for(unsigned i = 0; i < N; i++) {
for(unsigned j = i+1; j < N; j++) {
xAx Q = sources[i]-sources[j];
*notify << Q << " is a " << Q.categorise() << "\n";
}
}
{
cairo_save(cr);
cairo_set_source_rgba(cr, 0, 0, 1, 0.5);
::draw(cr, (sources[0]-sources[1]), screen_rect);
::draw(cr, (sources[0]-sources[2]), screen_rect);
::draw(cr, (sources[1]-sources[2]), screen_rect);
cairo_restore(cr);
}
{
string os;
for(unsigned i = 0; i < N; i++) {
for(unsigned j = i+1; j < N; j++) {
xAx Q = sources[i]-sources[j];
Interval iQ = Q.extrema(rh.pos);
if(iQ.contains(0)) {
os += stringify(iQ) + "\n";
Q.toCurve(rh.pos);
vector<Point> crs = Q.crossings(rh.pos);
for(unsigned ei = 0; ei < crs.size(); ei++) {
draw_cross(cr, crs[ei]);
}
}
}
//.........這裏部分代碼省略.........