本文整理汇总了C++中Point2D::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2D::getX方法的具体用法?C++ Point2D::getX怎么用?C++ Point2D::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2D
的用法示例。
在下文中一共展示了Point2D::getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
// Method for constructing rectangles using two points
Rectangle::Rectangle(Point2D& pOne, Point2D& pTwo)
{
width = abs(pOne.getX() - pTwo.getX());
height = abs(pOne.getY() - pTwo.getY());
// Find the coordinates of the rectangle
if (pOne.getX() <= pTwo.getX())
{
if (pOne.getY() <= pTwo.getY())
{
bottomLeft = pOne;
topRight = pTwo;
bottomRight = Point2D(topRight.getX(), bottomLeft.getY());
topLeft = Point2D(bottomLeft.getX(), topRight.getY());
} else {
topLeft = pOne;
bottomRight = pTwo;
bottomLeft = Point2D(topLeft.getX(), bottomRight.getY());
topRight = Point2D(bottomRight.getX(), topLeft.getY());
}
} else {
if (pOne.getY() <= pTwo.getY())
{
bottomRight = pOne;
topLeft = pTwo;
bottomLeft = Point2D(topLeft.getX(), bottomRight.getY());
topRight = Point2D(bottomRight.getX(), topLeft.getY());
} else {
topRight = pOne;
bottomLeft = pTwo;
bottomRight = Point2D(topRight.getX(), bottomLeft.getY());
topLeft = Point2D(bottomLeft.getX(), topRight.getY());
}
}
}
示例2:
bool operator<(const Point2D & p1, const Point2D & p2) {
if(p1.getY() < p2.getY())
return true;
if(p2.getY() < p1.getY())
return false;
return p1.getX() < p2.getX();
}
示例3:
Line2D::Line2D(Point2D pointA, Point2D pointB) {
Point2D b = pointA;
Point2D a = pointB;
y_intercept = -a.getX()*((b.getY() - a.getY()) / (b.getX() - a.getX())) + a.getY();
slope = (b.getY() - a.getY()) / (b.getX() - a.getX());
}
示例4: draw
void GhostCell::draw(Point2D cell) {
if (cell.getX() < 0 || cell.getY() < 0)
return;
appearance->apply();
glPushMatrix();
glTranslatef(-10, 0.251, -10);
glRotatef(-90, 1, 0, 0);
glTranslatef(cell.getY() * 2.5, cell.getX() * -2.5, 0);
glBegin(GL_QUADS);
glTexCoord2d(0, 0);
glVertex3d(0, -size, 0);
glTexCoord2d(1, 0);
glVertex3d(size, -size, 0);
glTexCoord2d(1, 1);
glVertex3d(size, 0, 0);
glTexCoord2d(0, 1);
glVertex3d(0, 0, 0);
glEnd();
glPopMatrix();
}
示例5: isInField
bool MotionExecutor::isInField(Point2D& enemyPosition){
static int xMinC=minX+margin;
static int xMaxC=maxX-margin;
static int yMinC=minY+margin;
static int yMaxC=maxY-margin;
static int xStairsMin=0-stairsWidth;
static int xStairsMax=0+stairsWidth;
static int yStairsMin=2000-stairsHeight;
static int yStairsMax=2000;
//TODO: proveri da nije slucajno na stepenklicama
if (((enemyPosition.getX()>xStairsMin) && (enemyPosition.getX()<xStairsMax)) &&
((enemyPosition.getY()>yStairsMin) && (enemyPosition.getY()<yStairsMax))){
debug("Enemy is on stairs");
return false;
}
if ((enemyPosition.getY()<yMinC) || (enemyPosition.getY()>yMaxC)){
return false;
}
if ((enemyPosition.getX()<xMinC) || (enemyPosition.getX()>xMaxC)){
return false;
}
if ((enemyPosition.getY()<yMinC) || (enemyPosition.getY()>yMaxC)){
return false;
}
return true;
}
示例6: getZOfPoint
Math::Point Projector::getZOfPoint(Point2D point) {
GLfloat pointZ;
glReadPixels(point.getX(),
currentDimensions.getY() - point.getY(),
1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pointZ);
return Math::Point(point.getX(), point.getY(), pointZ);
}
示例7: checkCollision
// Method for testing collision/intersection with a 2D point
bool Rectangle::checkCollision(Point2D& p)
{
if ((bottomLeft.getX() <= p.getX() && bottomRight.getX() >= p.getX()) &&
(bottomLeft.getY() <= p.getY() && topLeft.getY() >= p.getY()))
{
return true;
} else {
return false;
}
}
示例8: getBestDivide
double DoubleImage::getBestDivide(const Point2D& first, const Point2D& second, Channel channel) const {
if (dType == T_MIDDLE) {
return .5;
}
bool high = (dType == T_HIGHENTROPY);
if (!this->hasEdges()) {
throw logic_error("Edges not generated!");
}
double initialXDiff = second.getX() - first.getX();
double initialYDiff = second.getY() - first.getY();
Point2D point1(first.getX() + MIN_SUBDIVIDE_RATIO*(initialXDiff),
first.getY() + MIN_SUBDIVIDE_RATIO*(initialYDiff));
Point2D point2(first.getX() + (1-MIN_SUBDIVIDE_RATIO)*(initialXDiff),
first.getY() + (1-MIN_SUBDIVIDE_RATIO)*(initialYDiff));
vector<Point2D> points = getPointsOnLine(point1, point2);
double bestVal = -1;
double bestR = -1;
for (vector<Point2D>::const_iterator it = points.begin(); it != points.end(); it++) {
const double val = edgeAt(*it, channel);
if ( ((high)?(bestVal < val):(bestVal > val)) || bestR < 0) {
const double rx = (it->getX() - first.getX())/initialXDiff;
const double ry = (it->getY() - first.getY())/initialYDiff;
double r;
if (doublesEqual(initialXDiff, 0)) {
r = ry;
} else if (doublesEqual(initialYDiff, 0)) {
r = rx;
} else {
r = (rx+ry)/2.;
}
if (r > MIN_SUBDIVIDE_RATIO && r < 1-MIN_SUBDIVIDE_RATIO) {
bestR = r;
bestVal = val;
}
}
}
if (bestR < 0) {
return 1/2.0;
} else {
return bestR;
}
}
示例9: subimage
IntensityImageStudent ImageUtils::subimage(const IntensityImage * image, const Point2D<double> left_top, const Point2D<double> right_down)
{
int left_x = 0;
int right_x = image->getWidth();
int left_y = 0;
int right_y = image->getHeight();
if (left_top.getX() > right_down.getX()){
left_x = right_down.getX();
right_x = left_top.getX();
}
else if (left_top.getX() < right_down.getX()){
left_x = left_top.getX();
right_x = right_down.getX();
}
if (left_top.getY() > right_down.getY()){
left_y = right_down.getY();
right_y = left_top.getY();
}
else if (left_top.getY() < right_down.getY()){
left_y = left_top.getY();
right_y = right_down.getY();
}
IntensityImageStudent result(right_x - left_x, right_y - left_y);
for (int y = left_y; y < right_y; y++) {
for (int x = left_x; x < right_x; x++) {
result.setPixel(x - left_x, y - left_y, image->getPixel(x, y));
}
}
return result;
}
示例10:
Point2D Point2D::operator*(Point2D &p)
{
Point2D producto;
producto.x=x*p.getX();
producto.y=y*p.getY();
return producto;
}
示例11: cos
//Draw a line from a given position, with given length and angle
Point2D<double> StudentLocalization::drawLine(double angle, int len, Point2D<double> point) const{
angle = angle * M_PI / HALF_CIRCLE; // Convert degrees to radians
Point2D<double> point1;
point1.setX(point.getX() + len * cos(angle));
point1.setY(point.getY() + len * sin(angle));
return point1;
}
示例12: screenToGL
Math::Point Projector::screenToGL(Point2D point) {
Math::Point offset;
double orthoDim = Math::minimum(
currentDimensions.getX(),
currentDimensions.getY());
// offset is the value that translates by half the screen in the X and Y
// dimensions. Since due to resizeGL() above the viewport is set
// differently when width > height as when height > width, this complex
// code is necessary.
//
// offset is used to change the origin (0, 0) from the upper-left corner
// to the centre of the screen as is expected in OpenGL unit coordinates.
if(currentDimensions.getX() > currentDimensions.getY() || true) {
offset = Math::Point(
double(currentDimensions.getX()) / currentDimensions.getY(), -1.0);
}
else {
offset = Math::Point(1.0,
-double(currentDimensions.getY()) / currentDimensions.getX());
}
Math::Point unitPos(
point.getX() / orthoDim,
-point.getY() / orthoDim);
return 2.0 * unitPos - offset;
}
示例13: contains
bool contains(Point2D point) {
double ri = this->slope*point.getX() + this->y_intercept;
if (point.getY() < ri+0.00001 && point.getY() > ri - 0.00001)
return true;
return false;
}
示例14: setPosition
void MotionExecutor::setPosition(MotionCommand* _motionCommand){
SetPosition* command=(SetPosition*)_motionCommand;
debug(command->getSource()+" Received: Set position");
Point2D previousPosition =driver.getPosition();
currentMotionInstruction.Set(_motionCommand, lastState);
std::stringstream ss;
debug(ss.str());
pfLock.lock();
driver.setPositionAndOrientation(command->getPoint(),command->getOrientation());
for(int i=0;i<2;++i){
if (detectedEnemies[i].Id!=-1){
pathFinder->removeObstacle(detectedEnemies[i].Id);
detectedEnemies[i].Position.setX(detectedEnemies[i].Position.getX()+previousPosition.getX());
detectedEnemies[i].Position.setY(detectedEnemies[i].Position.getY()+previousPosition.getY());
detectedEnemies[i].CentralPosition.setX(detectedEnemies[i].CentralPosition.getX()+previousPosition.getX());
detectedEnemies[i].CentralPosition.setY(detectedEnemies[i].CentralPosition.getY()+previousPosition.getY());
// detectedEnemies[i].Id=dodajSestougao(detectedEnemies[i].Position.getX(),
// detectedEnemies[i].Position.getY(),
// triangleSide,driver.getOrientation());
detectedEnemies[i].Id=dodajCustomOblik(detectedEnemies[i].Position.getX(),
detectedEnemies[i].Position.getY(),
driver.getOrientation());
}
}
pfLock.unlock();
}
示例15: pointInside
bool Rectangle::pointInside(const Point2D& point) const {
double px = point.getX();
double py = point.getY();
return (((px >= this->x || doublesEqual(px, this->x)) &&
(px <= this->x+this->w || doublesEqual(px, this->x+this->w))) &&
((py >= this->y || doublesEqual(py, this->y)) &&
(px <= this->y+this->h || doublesEqual(py, this->y+this->h))));
}