当前位置: 首页>>代码示例>>C++>>正文


C++ Coord::getY方法代码示例

本文整理汇总了C++中Coord::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ Coord::getY方法的具体用法?C++ Coord::getY怎么用?C++ Coord::getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coord的用法示例。


在下文中一共展示了Coord::getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cutLineVertical

void Geometry::cutLineVertical(Coord * a, Coord * b, int lineLow, int lineHigh)
{
    Coord * lowPoint;
    Coord * highPoint;
    if(a->getX() < b->getX())
    {
        lowPoint = a;
        highPoint = b;
    }
    else
    {
        lowPoint = b;
        highPoint = a;
    }
    
    if(lowPoint->getX() < lineLow)
    {
        int overLength = lineLow - lowPoint->getX();
        float removeFactor = overLength/(float)(highPoint->getX()-lowPoint->getX());
        lowPoint->add(overLength,(int)((highPoint->getY()-lowPoint->getY())*removeFactor));
    }

    if(highPoint->getX() > lineHigh)
    {
        int overLength = highPoint->getX() - lineHigh;
        float removeFactor = overLength/(float)(highPoint->getX()-lowPoint->getX());
        highPoint->add(-overLength,(int)(-(highPoint->getY()-lowPoint->getY())*removeFactor));
    }
}
开发者ID:nessotrin,项目名称:Spassus2,代码行数:29,代码来源:Geometry.cpp

示例2: move

void Model::move(int x,int y, bool hasMoved, uint32_t* numThread) {
    int kind = matrix(x,y)->getKind();
    // If the cell is empty
    // a human may be born
    if (kind == EMPTY) {
        if (timeToBeBorn(numThread)) {
            matrix.set(x, y, HUMAN, numThread);
        }
        // Otherwise, the person in the cell moves
    } else if (matrix(x,y)->getMoveFlag() == hasMoved) {
        Coord crd = Coord(x, y);
        switch(kind) {
        case HUMAN :
            crd = moveHuman(x, y, numThread);
            break;
        case INFECTED :
            crd = moveInfected(x, y, numThread);
            break;
        case ZOMBIE :
            crd = moveZombie(x, y, numThread);
            break;
        }
        // Update moveFlags for the non-empty cells only
        // Very important when multi-threading (because of the dummy)
        if (matrix(x,y)->getKind() != EMPTY) {
            // The square (x, y) has been considered
            matrix(x,y)->setMoveFlag(!hasMoved);
        }
        if (matrix(crd.getX(), crd.getY())->getKind() != EMPTY) {
            // If the person in (x,y) has moved, updata the move Flag of the destination
            matrix(crd.getX(), crd.getY())->setMoveFlag(!hasMoved);
        }
    }
}
开发者ID:johanwikstrm,项目名称:zombies,代码行数:34,代码来源:Model.cpp

示例3: pixelDist

double pixelDist(Coord c1, Coord c2)
{
  double xSq, ySq;
  xSq = c2.getX() - c1.getX(); 
  xSq = xSq * xSq;
  ySq = c2.getY() - c1.getY();
  ySq = ySq * ySq;

  return sqrt( xSq + ySq );
}
开发者ID:SDSMT-CSC464-F15,项目名称:landingpad,代码行数:10,代码来源:cv_tracker.cpp

示例4:

Rectangle::Rectangle(Coord p_coord, double p_width, double p_height, double p_angle, int p_lineStroke, ofColor p_lineColor, ofColor p_lineColorSelected, ofColor p_colorFill)
    : Shape2D(p_angle, p_lineStroke, p_lineColor, p_lineColorSelected, p_colorFill) {
    m_width = p_width;
    m_height = p_height;
    m_coordVector = std::vector<Coord>();
    m_coordVector.push_back(p_coord);
    m_coordVector.push_back(Coord(p_coord.getX() + p_width, p_coord.getY()));
    m_coordVector.push_back(Coord(p_coord.getX() + p_width, p_coord.getY() + p_height));
    m_coordVector.push_back(Coord(p_coord.getX(), p_coord.getY() + p_height));

    m_type = EnumVectorDrawMode::VECTOR_PRIMITIVE_RECTANGLE;
}
开发者ID:marcelbernic,项目名称:src,代码行数:12,代码来源:Rectangle.cpp

示例5: pointInsidePolygon

// found on http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
bool pointInsidePolygon(const vector<Coord> &polygon, const Coord &point) {
  unsigned int i, j;
  bool ret = false;

  for (i = 0, j = polygon.size() - 1 ; i < polygon.size() ; j = i++) {
    if ((((polygon[i].getY() <= point.getY()) && (point.getY() < polygon[j].getY())) ||
         ((polygon[j].getY() <= point.getY()) && (point.getY() < polygon[i].getY()))) &&
        (point.getX() < (polygon[j].getX() - polygon[i].getX()) * (point.getY() - polygon[i].getY()) / (polygon[j].getY() - polygon[i].getY()) + polygon[i].getX()))
      ret = !ret;
  }

  return ret;
}
开发者ID:mneumann,项目名称:tulip,代码行数:14,代码来源:MouseLassoNodesSelector.cpp

示例6: drawLabel

void GlAxisBoxPlot::drawLabel(const Coord& position, const string& labelName, Camera *camera) {
  float labelHeight = axis->getLabelHeight();

  float heightRef;

  if (axis->hasAscendingOrder()) {
    heightRef = topOutlierCoord.getY() - thirdQuartileCoord.getY();
  }
  else {
    heightRef = thirdQuartileCoord.getY() - topOutlierCoord.getY();
  }

  if (labelHeight > heightRef) {
    labelHeight = heightRef / 2.0f;
  }

  float labelWidth = labelName.length() * (labelHeight / 2.0f);

  if (labelName.length() == 1) {
    labelWidth *= 2.0f;
  }

  GlLabel labelToDraw(Coord(position.getX() - boxWidth / 2.0f - labelWidth / 2.0f, position.getY(), 0.0f),
                      Size(labelWidth, labelHeight), outlineColor);
  labelToDraw.setText(labelName);
  labelToDraw.draw(0, camera);
}
开发者ID:mneumann,项目名称:tulip,代码行数:27,代码来源:ParallelCoordsAxisBoxPlot.cpp

示例7: draw

bool MouseMagnifyingGlassInteractorComponent::draw(GlMainWidget *glWidget) {
  if (!drawInteractor) {
    return false;
  }

  camera->initGl();
  Coord boxCenterScr = camera->worldTo2DViewport(boxCenter);
  Camera camera2D(camera->getScene(), false);
  camera2D.setScene(camera->getScene());
  camera2D.initGl();
  glDisable(GL_LIGHTING);
  glDisable(GL_BLEND);
  glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  glPushMatrix();
  glTranslatef(boxCenterScr.getX(), boxCenterScr.getY(), 0);

  Color outlineColor;
  int bgV = glWidget->getScene()->getBackgroundColor().getV();

  if (bgV < 128) {
    outlineColor = Color(255,255,255);
  }
  else {
    outlineColor = Color(0,0,0);
  }

  GlCircle circle(Coord(0,0,0), radius, outlineColor, Color::White, true, true, 0.0, 60);
  circle.setOutlineSize(3);
  circle.setTextureName(textureName);
  circle.draw(0,0);

  glPopMatrix();
  drawInteractor = false;
  return true;
}
开发者ID:mneumann,项目名称:tulip,代码行数:35,代码来源:MouseMagnifyingGlass.cpp

示例8: mercatorProjection

Coord GoogleMaps::mercatorProjection(const Coord &swPixel, const Coord &nePixel, const double latitude, const double longitude) {
  double dLng = longitude + 180.0;
  double latRadians = M_PI * latitude / 180.0;
  double worldHeight = nePixel[1] - swPixel[1];
  double worldWidth = nePixel[0] - swPixel[0];
  double y = worldHeight / 2.0 + log(tan(M_PI/4.0 + latRadians / 2.0)) * worldWidth / (2 * M_PI);
  return Coord(swPixel.getX() + (dLng / 360.0) * worldWidth, swPixel.getY() + y);
}
开发者ID:mneumann,项目名称:tulip,代码行数:8,代码来源:GoogleMaps.cpp

示例9: GlLabel

PixelOrientedOverview::PixelOrientedOverview(TulipGraphDimension *data,
                                             PixelOrientedMediator *pixelOrientedMediator,
                                             Coord blCornerPos, const std::string &dimName,
                                             const Color &backgroundColor, const Color &textColor)
    : data(data), pixelOrientedMediator(pixelOrientedMediator), blCornerPos(blCornerPos),
      dimName(dimName), frame(nullptr), frame2(nullptr), overviewGen(false),
      backgroundColor(backgroundColor), textColor(textColor) {

  if (this->dimName.empty()) {
    this->dimName = data->getDimensionName();
  }

  overviewId = overviewCpt++;

  textureName = dimName + " texture " + getStringFromNumber(overviewId);

  unsigned int width = pixelOrientedMediator->getImageWidth();
  unsigned int height = pixelOrientedMediator->getImageHeight();

  unsigned int labelHeight = height / 4;

  Graph *graph = data->getTulipGraph();
  pixelLayout = new LayoutProperty(graph);
  pixelSize = new SizeProperty(graph);
  graphComposite = new GlGraphComposite(graph);
  setGraphView(graphComposite);
  GlGraphInputData *glGraphInputData = graphComposite->getInputData();
  glGraphInputData->setElementLayout(pixelLayout);
  glGraphInputData->setElementSize(pixelSize);

  frame = new GlRect(Coord(blCornerPos.getX() - 3, blCornerPos.getY() + height + 3),
                     Coord(blCornerPos.getX() + width + 3, blCornerPos.getY() - 3), Color(0, 0, 0),
                     Color(0, 0, 0), false, true);
  addGlEntity(frame, dimName + "frame");
  frame2 = new GlRect(Coord(blCornerPos.getX() - 4, blCornerPos.getY() + height + 4),
                      Coord(blCornerPos.getX() + width + 4, blCornerPos.getY() - 4), Color(0, 0, 0),
                      Color(0, 0, 0), false, true);
  addGlEntity(frame2, dimName + "frame 2");

  backgroundRect = new GlRect(Coord(blCornerPos.getX(), blCornerPos.getY() + height),
                              Coord(blCornerPos.getX() + width, blCornerPos.getY()),
                              Color(255, 255, 255), Color(255, 255, 255), true, false);
  addGlEntity(backgroundRect, "background rect");
  clickLabel = new GlLabel(Coord(blCornerPos.getX() + width / 2, blCornerPos.getY() + height / 2),
                           Size(width, height / 4), Color(0, 0, 0));
  clickLabel->setText("Double Click to generate overview");
  addGlEntity(clickLabel, "label");

  computeBoundingBox();

  overviewLabel =
      new GlLabel(Coord(blCornerPos.getX() + width / 2, blCornerPos.getY() - labelHeight / 2),
                  Size(width, labelHeight), textColor);
  overviewLabel->setText(dimName);
  addGlEntity(overviewLabel, "overview label");
}
开发者ID:tulip5,项目名称:tulip,代码行数:56,代码来源:PixelOrientedOverview.cpp

示例10: checkCollision

//TODO
bool Triangle::checkCollision(Coord p_clickPoint, double p_radius) {
	Coord coord1 = m_coordVector[0];
	Coord coord2 = m_coordVector[1];
	Coord coord3 = m_coordVector[2];
	double angle1, angle2, angle3;
	double total;


	//Check if a corner of the triangle is in the circle
	if (calculateDistance(p_clickPoint, coord1) <= p_radius) return true;
	if (calculateDistance(p_clickPoint, coord2) <= p_radius) return true;
	if (calculateDistance(p_clickPoint, coord3) <= p_radius) return true;

	//Check for line/circle collisions
	if (checkCollisionLineCircle(coord1, coord2, p_clickPoint, p_radius)) return true;
	if (checkCollisionLineCircle(coord2, coord3, p_clickPoint, p_radius)) return true;
	if (checkCollisionLineCircle(coord3, coord1, p_clickPoint, p_radius)) return true;

	//Build vectors with each center/corner combination
	double vector1[] {coord1.getX() - p_clickPoint.getX(), coord1.getY() - p_clickPoint.getY()};
	double vector2[] {coord2.getX() - p_clickPoint.getX(), coord2.getY() - p_clickPoint.getY()};
	double vector3[] {coord3.getX() - p_clickPoint.getX(), coord3.getY() - p_clickPoint.getY()};

	//Check if the circle's center is in the triangle
	angle1 = calculateAngle(vector1, vector2);
	//System.out.println("Angle1 180");
	if (angle1 > 180)return false;
	angle2 = calculateAngle(vector2, vector3);
	//System.out.println("Angle2 180");
	if (angle2 > 180)return false;
	angle3 = calculateAngle(vector3, vector1);
	//System.out.println("Angle3 180");
	if (angle3 > 180)return false;

	total = angle1 + angle2 + angle3;

	//System.out.println(angle1);
	//System.out.println(angle2);
	//System.out.println(angle3);
	//System.out.println(total);
	//System.out.println(Math.ceil(total) == 360);
	//System.out.println("Fin\n***************************************\n\n");

	return round(total) == 360;
}
开发者ID:marcelbernic,项目名称:src,代码行数:46,代码来源:Triangle.cpp

示例11: containedInRect

bool Rectangle::containedInRect(Coord p_topLeft, double p_width, double p_height) {
    double distanceX = 0;
    double distanceY = 0;
    for (Coord c : m_coordVector) {
        distanceX = c.getX() - p_topLeft.getX();
        distanceY = c.getY() - p_topLeft.getY();
        if (distanceX <= p_width && distanceY <= p_height && distanceX >= 0 && distanceY >= 0) return true;
    }
    return false;
}
开发者ID:marcelbernic,项目名称:src,代码行数:10,代码来源:Rectangle.cpp

示例12: getAnchor

//=============================================
Coord Glyph::getAnchor(const Coord &nodeCenter, const Coord &from, const Size &scale, const double zRotation) const {
  Coord anchor = from - nodeCenter;

  if( anchor.getX() == 0.0f && anchor.getY() == 0.0f)
    return nodeCenter;

  if( scale.getW() == 0.0f || scale.getH() == 0.0f)
    return nodeCenter;

  if(zRotation!=0) {
    //unrotate
    Coord saveAnchor(anchor);
    double zRot =  - 2.0*M_PI * zRotation / 360.0;
    anchor[0] = saveAnchor[0]*cos(zRot) - saveAnchor[1]*sin(zRot);
    anchor[1] = saveAnchor[0]*sin(zRot) + saveAnchor[1]*cos(zRot);
  }

  // unscale
  anchor.setX( anchor.getX() / scale.getW() );
  anchor.setY( anchor.getY() / scale.getH() );

  if(scale.getD() != 0.0f)
    anchor.setZ( anchor.getZ() / scale.getD() );
  else
    anchor.setZ(0.0f);

  anchor = getAnchor( anchor );

  // rescale
  anchor.setX( anchor.getX() * scale.getW() );
  anchor.setY( anchor.getY() * scale.getH() );
  anchor.setZ( anchor.getZ() * scale.getD() );

  if(zRotation!=0) {
    //rerotate
    Coord saveAnchor(anchor);
    double zRot = 2.0*M_PI * zRotation / 360.0;
    anchor[0] = saveAnchor[0]*cos(zRot) - saveAnchor[1]*sin(zRot);
    anchor[1] = saveAnchor[0]*sin(zRot) + saveAnchor[1]*cos(zRot);
  }

  return nodeCenter + anchor;
}
开发者ID:mneumann,项目名称:tulip,代码行数:44,代码来源:Glyph.cpp

示例13: zoomOnScreenRegionWithoutAnimation

void zoomOnScreenRegionWithoutAnimation(GlMainWidget *glWidget, const BoundingBox &boundingBox) {
  Camera &camera = glWidget->getScene()->getGraphCamera();
  Coord bbScreenFirst = camera.worldTo2DViewport(Coord(boundingBox[0]));
  Coord bbScreenSecond = camera.worldTo2DViewport(Coord(boundingBox[1]));
  float bbWidthScreen = bbScreenSecond.getX() - bbScreenFirst.getX();
  float bbHeightScreen = bbScreenSecond.getY() - bbScreenFirst.getY();

  bbWidthScreen += bbWidthScreen * .1;
  bbHeightScreen += bbHeightScreen * .1;

  float startSize, endSize;

  if (bbHeightScreen < bbWidthScreen) {
    startSize = glWidget->width();
    endSize = bbWidthScreen;
  }
  else {
    startSize = glWidget->height();
    endSize = bbHeightScreen;
  }

  float zoomFactor = startSize / endSize;

  double zoomStart = camera.getZoomFactor();
  double zoomEnd = zoomStart * zoomFactor;
  bool withZoom = zoomFactor < 0.99 || zoomFactor > 1.01;

  Coord newCamCenter = (Coord(boundingBox[0]) + Coord(boundingBox[1])) / ((float)2.0);
  newCamCenter.setZ(boundingBox[0][2]);

  camera.setCenter(newCamCenter);
  camera.setEyes(Coord(0, 0, camera.getSceneRadius()));
  camera.setEyes(camera.getEyes() + camera.getCenter());
  camera.setUp(Coord(0, 1., 0));

  if (withZoom) {
    camera.setZoomFactor(zoomEnd);
  }
}
开发者ID:mneumann,项目名称:tulip,代码行数:39,代码来源:ZoomUtils.cpp

示例14: pSurface

void    ZoomAnimation::OnRender()
{
    std::auto_ptr<Surface> pSurface( getSurface()->ZoomSurface( m_curZoom ) );
    if(pSurface.get() == 0) {
    	return;
    }

    Dim destDim = pSurface->GetDim();
    Dim srcDim = getSurface()->GetDim();
    Coord srcCoord = getCoord();
    
    // 그림이 확대, 축소되면 이미지 위치로 확대 축소된 값에 따라 변한다.
    int x = srcCoord.getX() + (srcDim.getW() - destDim.getW() ) / 2;
    int y = srcCoord.getY() + (srcDim.getH() - destDim.getH() ) / 2;
    
    pSurface->SetColorKey();
    pSurface->Blit( x, y );
    pSurface->Free();
}
开发者ID:beebopkim,项目名称:KickItUp,代码行数:19,代码来源:ZoomAnimation.cpp

示例15: checkCollision

//TODO
bool Rectangle::checkCollision(Coord p_clickPoint, double p_radius) {
    //Rotate circle center from rectangle top-left corner standpoint
    double x = p_clickPoint.getX() - m_coordVector[0].getX();
    double y = p_clickPoint.getY() - m_coordVector[0].getY();
    double circleRotatedX = (x*cos(-m_angle*PI / 180) - y*sin(-m_angle*PI / 180)) + m_coordVector[0].getX();
    double circleRotatedY = (x*sin(-m_angle*PI / 180) + y*cos(-m_angle*PI / 180)) + m_coordVector[0].getY();

    //Hitbox detection
    double centerX = m_coordVector[0].getX() + (m_width / 2);
    double centerY = m_coordVector[0].getY() + (m_height / 2);

    double distanceX = abs(circleRotatedX - centerX);
    double distanceY = abs(circleRotatedY - centerY);

    if (distanceX > ((m_width / 2) + p_radius)) return false;
    if (distanceY > ((m_height / 2) + p_radius)) return false;

    if (distanceX <= (m_width / 2)) return true;
    if (distanceY <= (m_height / 2)) return true;

    double distanceCornerToCenter = pow(distanceX - (m_width / 2), 2) + pow(distanceY - (m_height / 2), 2);
    return distanceCornerToCenter <= pow(p_radius, 2);
}
开发者ID:marcelbernic,项目名称:src,代码行数:24,代码来源:Rectangle.cpp


注:本文中的Coord::getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。