这篇教程C++ y函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中y函数的典型用法代码示例。如果您正苦于以下问题:C++ y函数的具体用法?C++ y怎么用?C++ y使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了y函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rotated /** * Like rotate(), but returns a new point instead of changing *this */ Point rotated(float angle) const { float newX = x() * cos(angle) - y() * sin(angle); float newY = y() * cos(angle) + x() * sin(angle); return Point(newX, newY); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:8,
示例2: isBoxIntersectingTrianglebool isBoxIntersectingTriangle(const Box_f & box, const Triangle_f & triangle) { /* use separating axis theorem to test overlap between triangle and box */ /* need to test for overlap in these directions: */ /* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */ /* we do not even need to test these) */ /* 2) normal of the triangle */ /* 3) crossproduct(edge from tri, {x,y,z}-directin) */ /* this gives 3x3=9 more tests */ Vec3 boxcenter = box.getCenter(); Vec3 boxhalfsize(0.5f * box.getExtentX(), 0.5f * box.getExtentY(), 0.5f * box.getExtentZ()); /* This is the fastest branch on Sun */ /* move everything so that the boxcenter is in (0,0,0) */ const auto v0 = triangle.getVertexA() - boxcenter; const auto v1 = triangle.getVertexB() - boxcenter; const auto v2 = triangle.getVertexC() - boxcenter; /* compute triangle edges */ const auto e0 = triangle.getEdgeAB(); const auto e1 = triangle.getEdgeBC(); const auto e2 = triangle.getEdgeCA(); /* Bullet 3: */ /* test the 9 tests first (this was faster) */ float p0, p1, p2, rad, pMin, pMax; Vec3 fe = e0.getAbs(); p0 = e0.z() * v0.y() - e0.y() * v0.z(); p2 = e0.z() * v2.y() - e0.y() * v2.z(); if (p0 < p2) { pMin = p0; pMax = p2; } else { pMin = p2; pMax = p0; } rad = fe.z() * boxhalfsize.y() + fe.y() * boxhalfsize.z(); if (pMin > rad || pMax < -rad) return 0; p0 = -e0.z() * v0.x() + e0.x() * v0.z(); p2 = -e0.z() * v2.x() + e0.x() * v2.z(); if (p0 < p2) { pMin = p0; pMax = p2; } else { pMin = p2; pMax = p0; } rad = fe.z() * boxhalfsize.x() + fe.x() * boxhalfsize.z(); if (pMin > rad || pMax < -rad) return 0; p1 = e0.y() * v1.x() - e0.x() * v1.y(); p2 = e0.y() * v2.x() - e0.x() * v2.y(); if (p2 < p1) { pMin = p2; pMax = p1; } else { pMin = p1; pMax = p2; } rad = fe.y() * boxhalfsize.x() + fe.x() * boxhalfsize.y(); if (pMin > rad || pMax < -rad) return 0; fe = e1.getAbs(); p0 = e1.z() * v0.y() - e1.y() * v0.z(); p2 = e1.z() * v2.y() - e1.y() * v2.z(); if (p0 < p2) { pMin = p0; pMax = p2; } else { pMin = p2; pMax = p0; } rad = fe.z() * boxhalfsize.y() + fe.y() * boxhalfsize.z(); if (pMin > rad || pMax < -rad) return 0; p0 = -e1.z() * v0.x() + e1.x() * v0.z(); p2 = -e1.z() * v2.x() + e1.x() * v2.z(); if (p0 < p2) { pMin = p0; pMax = p2; } else { pMin = p2; pMax = p0; } rad = fe.z() * boxhalfsize.x() + fe.x() * boxhalfsize.z(); if (pMin > rad || pMax < -rad) return 0; p0 = e1.y() * v0.x() - e1.x() * v0.y(); p1 = e1.y() * v1.x() - e1.x() * v1.y(); if (p0 < p1) { pMin = p0; pMax = p1; } else {//.........这里部分代码省略.........
开发者ID:PADrend,项目名称:Geometry,代码行数:101,
示例3: xbool FloatRect::contains(const FloatRect& other) const{ return x() <= other.x() && maxX() >= other.maxX() && y() <= other.y() && maxY() >= other.maxY();}
开发者ID:3163504123,项目名称:phantomjs,代码行数:5,
示例4: rect//-----------------------------------------------------------------------------// Function: setBottomCoordinate()//-----------------------------------------------------------------------------void AddressSpaceVisualizationItem::setBottomCoordinate(qreal yCoordinate) { qreal width = rect().width(); qreal height = yCoordinate - y(); setRect(0, 0, width, height); VisualizerItem::reorganizeChildren();}
开发者ID:kammoh,项目名称:kactus2,代码行数:9,
示例5: Scheduler void system::set_geometry(const bool init) { const double dt_max = 1.0/512; scheduler = Scheduler(dt_max); int np; float lx, ly, lz; FILE *fin = NULL; if (myproc == 0) { float wp; fin = fopen(fin_data, "r"); int ival; size_t nread; nread = fread(&ival, sizeof(int), 1, fin); assert(ival == 2*sizeof(int)); nread = fread(&np, sizeof(int), 1, fin); nread = fread(&wp, sizeof(float), 1, fin); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == 2*sizeof(int)); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == 3*sizeof(float)); nread = fread(&lx, sizeof(float), 1, fin); nread = fread(&ly, sizeof(float), 1, fin); nread = fread(&lz, sizeof(float), 1, fin); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == 3*sizeof(float)); fprintf(stderr, " np= %d wp= %g /n",np, wp); fprintf(stderr, " lx= %g ly= %g lz= %g /n", lx, ly, lz); } MPI_Bcast(&lx, 1, MPI_FLOAT, 0, MPI_COMM_WORLD); MPI_Bcast(&ly, 1, MPI_FLOAT, 0, MPI_COMM_WORLD); MPI_Bcast(&lz, 1, MPI_FLOAT, 0, MPI_COMM_WORLD); t_end = 0.2; n_restart = 2; dt_restart = dt_max; dt_dump = 0.01; di_log = 100; global_n = local_n = 0;// eulerian = true; const vec3 rmin(0.0); const vec3 rmax(lx, ly, lz); global_domain = boundary(rmin, rmax); global_domain_size = global_domain.hsize() * 2.0; const vec3 Len3 = global_domain.hsize() * 2.0; pfloat<0>::set_scale(Len3.x); pfloat<1>::set_scale(Len3.y); pfloat<2>::set_scale(Len3.z); if (myproc == 0) { ptcl.resize(np); const int nx = (int)std::pow(np, 1.0/3.0); const dvec3 dr = dvec3(Len3.x/nx, Len3.y/nx, Len3.z/nx); const real rmax = dr.abs() * 1.0; fprintf(stderr, "dr= %g %g %g /n", dr.x, dr.y, dr.z); local_n = ptcl.size(); global_n = local_n; { std::vector<float> x(local_n), y(local_n), z(local_n); size_t nread; int ival; nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); nread = fread(&x[0], sizeof(float), local_n, fin); assert((int)nread == local_n); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); nread = fread(&y[0], sizeof(float), local_n, fin); assert((int)nread == local_n); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); nread = fread(&z[0], sizeof(float), local_n, fin); assert((int)nread == local_n); nread = fread(&ival, sizeof(int), 1, fin); assert(ival == local_n*(int)sizeof(float)); for (int i = 0; i < local_n; i++) { const dvec3 vel(0.0, 0.0, 0.0); ptcl[i] = Particle(x[i], y[i], z[i], vel.x, vel.y, vel.z, i); ptcl[i].rmax = rmax; ptcl[i].unset_derefine(); } }//.........这里部分代码省略.........
开发者ID:QirongZhu,项目名称:fvmhd3d,代码行数:101,
示例6: toQPointF /** * to draw stuff and interface with QT */ QPointF toQPointF() const { return QPointF(x(), y()); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:4,
示例7: Point operator Packet::Point() const { Packet::Point out; out.set_x(x()); out.set_y(y()); return out; }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:6,
示例8: cross float cross(const Point& other) const { return x() * other.y() - y() * other.x(); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:3,
示例9: toString std::string toString() const { std::stringstream str; str << "Point(" << x() << ", " << y() << ")"; return str.str(); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:5,
示例10: perpCCW /** returns the perpendicular to the point, Counter Clockwise */ Point perpCCW() const { return Point(-y(), x()); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:2,
示例11: perpCW /** returns the perpendicular to the point, Clockwise */ Point perpCW() const { return Point(y(), -x()); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:2,
示例12: angle /** * Returns the angle of this point in radians CCW from +X. */ float angle() const { return atan2(y(), x()); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:4,
示例13: draw/*! Draw dots /param painter Painter /param xMap x map /param yMap y map /param from index of the first point to be painted /param to index of the last point to be painted /sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()*/void QwtPlotCurve::drawDots(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const{ const QRect window = painter->window(); if ( window.isEmpty() ) return; const bool doFill = d_data->brush.style() != Qt::NoBrush; QwtPolygon polyline; if ( doFill ) polyline.resize(to - from + 1); if ( to > from && d_data->paintAttributes & PaintFiltered ) { if ( doFill ) { QPoint pp( xMap.transform(x(from)), yMap.transform(y(from)) ); QwtPainter::drawPoint(painter, pp.x(), pp.y()); polyline.setPoint(0, pp); int count = 1; for (int i = from + 1; i <= to; i++) { const QPoint pi(xMap.transform(x(i)), yMap.transform(y(i))); if ( pi != pp ) { QwtPainter::drawPoint(painter, pi.x(), pi.y()); polyline.setPoint(count, pi); count++; pp = pi; } } if ( int(polyline.size()) != count ) polyline.resize(count); } else { // if we don't need to fill, we can sort out // duplicates independent from the order PrivateData::PixelMatrix pixelMatrix(window); for (int i = from; i <= to; i++) { const QPoint p( xMap.transform(x(i)), yMap.transform(y(i)) ); if ( pixelMatrix.testPixel(p) ) QwtPainter::drawPoint(painter, p.x(), p.y()); } } } else { for (int i = from; i <= to; i++) { const int xi = xMap.transform(x(i)); const int yi = yMap.transform(y(i)); QwtPainter::drawPoint(painter, xi, yi); if ( doFill ) polyline.setPoint(i - from, xi, yi); } } if ( doFill ) { if ( d_data->paintAttributes & ClipPolygons ) polyline = QwtClipper::clipPolygon(painter->window(), polyline); fillCurve(painter, xMap, yMap, polyline); }}
开发者ID:alex-krutikov,项目名称:MkStudio,代码行数:89,
示例14: widthvoid Edit::resizeEvent(QResizeEvent *){ button->setGeometry((x() + width() + (height() * 0.4)) - height(), y() + (height() * 0.3),height() * 0.4,height() * 0.4);}
开发者ID:0marcos0,项目名称:Pedyrum,代码行数:5,
示例15: isWithinIntRangebool FloatRect::isExpressibleAsIntRect() const{ return isWithinIntRange(x()) && isWithinIntRange(y()) && isWithinIntRange(width()) && isWithinIntRange(height()) && isWithinIntRange(maxX()) && isWithinIntRange(maxY());}
开发者ID:3163504123,项目名称:phantomjs,代码行数:6,
示例16: containsbool FloatRect::contains(const FloatPoint& point, ContainsMode containsMode) const{ if (containsMode == InsideOrOnStroke) return contains(point.x(), point.y()); return x() < point.x() && maxX() > point.x() && y() < point.y() && maxY() > point.y();}
开发者ID:3163504123,项目名称:phantomjs,代码行数:6,
示例17: sizevoid BtModuleManagerDialog::saveDialogSettings() { CBTConfig::set(CBTConfig::bookshelfWidth, size().width()); CBTConfig::set(CBTConfig::bookshelfHeight, size().height()); CBTConfig::set(CBTConfig::bookshelfPosX, x()); CBTConfig::set(CBTConfig::bookshelfPosY, y());}
开发者ID:bibletime,项目名称:historic-bibletime-svn,代码行数:6,
示例18: x /** * see operator+ * this modifies the value instead of returning a new value */ Point& operator+=(Point other) { x() += other.x(); y() += other.y(); return *this; }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:10,
示例19: mainauto Curry=[](auto x,auto y){return[=]{auto i=x();while(i--)y();};};#include <iostream>int main() { auto foo = Curry([]{return 12;}, []{std::cout << "y/n";}); foo();}
开发者ID:CCJY,项目名称:coliru,代码行数:8,
示例20: setCurveAttribute/*! /brief Draw lines If the CurveAttribute Fitted is enabled a QwtCurveFitter tries to interpolate/smooth the curve, before it is painted. /param painter Painter /param xMap x map /param yMap y map /param from index of the first point to be painted /param to index of the last point to be painted /sa setCurveAttribute(), setCurveFitter(), draw(), drawLines(), drawDots(), drawSteps(), drawSticks()*/void QwtPlotCurve::drawLines(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const{ int size = to - from + 1; if ( size <= 0 ) return; QwtPolygon polyline; if ( ( d_data->attributes & Fitted ) && d_data->curveFitter ) { // Transform x and y values to window coordinates // to avoid a distinction between linear and // logarithmic scales.#if QT_VERSION < 0x040000 QwtArray<QwtDoublePoint> points(size);#else QPolygonF points(size);#endif for (int i = from; i <= to; i++) { QwtDoublePoint &p = points[i]; p.setX( xMap.xTransform(x(i)) ); p.setY( yMap.xTransform(y(i)) ); } points = d_data->curveFitter->fitCurve(points); size = points.size(); if ( size == 0 ) return; // Round QwtDoublePoints to QPoints // When Qwt support for Qt3 has been dropped (Qwt 6.x) // we will use a doubles for painting and the following // step will be obsolete. polyline.resize(size); const QwtDoublePoint *p = points.data(); QPoint *pl = polyline.data(); if ( d_data->paintAttributes & PaintFiltered ) { QPoint pp(qRound(p[0].x()), qRound(p[0].y())); pl[0] = pp; int count = 1; for (int i = 1; i < size; i++) { const QPoint pi(qRound(p[i].x()), qRound(p[i].y())); if ( pi != pp ) { pl[count++] = pi; pp = pi; } } if ( count != size ) polyline.resize(count); } else { for ( int i = 0; i < size; i++ ) { pl[i].setX( qRound(p[i].x()) ); pl[i].setY( qRound(p[i].y()) ); } } } else { polyline.resize(size); if ( d_data->paintAttributes & PaintFiltered ) { QPoint pp( xMap.transform(x(from)), yMap.transform(y(from)) ); polyline.setPoint(0, pp); int count = 1; for (int i = from + 1; i <= to; i++) { const QPoint pi(xMap.transform(x(i)), yMap.transform(y(i))); if ( pi != pp ) {//.........这里部分代码省略.........
开发者ID:alex-krutikov,项目名称:MkStudio,代码行数:101,
示例21: QString QString Rect::toString() const { return QString("Rect {x: %1, y: %2, width: %3, height: %4}").arg(x()).arg(y()).arg(width()).arg(height()); }
开发者ID:sakazuki,项目名称:actiona,代码行数:4,
示例22: mag /** computes magnitude squared this is faster than mag() @return the magnitude squared */ float magsq() const { return x() * x() + y() * y(); }
开发者ID:justbuchanan,项目名称:robocup-software,代码行数:6,
注:本文中的y函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ y0函数代码示例 C++ xzalloc函数代码示例 |