本文整理汇总了C++中Coordinate::GetX方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::GetX方法的具体用法?C++ Coordinate::GetX怎么用?C++ Coordinate::GetX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinate
的用法示例。
在下文中一共展示了Coordinate::GetX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline int Coordinate::operator<(const Coordinate &rhs) const
{
if (x == rhs.GetX())
return y < rhs.GetY();
else
return x < rhs.GetX();
}
示例2: CheckMove
bool Rock::CheckMove(Coordinate currentPosition, Coordinate movePosition, bool allowDoCornerStep){
if (currentPosition.GetX() == movePosition.GetX() || currentPosition.GetY() == movePosition.GetY())
return true;
return false;
}
示例3: DrawLineBresenham
/*
* Das ist die Standart Bresenham-Algorithmus.
* Die Lage der Punkte wird nicht geprüft, sondern davon ausgegangen, dass dies schon passiert ist.
* Die Angabe des Orthanden und der Basis dient der Translation der Koordinaten.
*/
void PrimitiveLine::DrawLineBresenham(ImageBase *img, const Coordinate &to,const char orthant, const Coordinate &offset) const {
int deltaX = to.GetX();
int deltaY = to.GetY();
int e= 2*deltaY - deltaX;
int x = 0;
int y = 0;
Coordinate coord;
while( x <= deltaX ) {
/* Ruecktransformation der Koordinaten */
coord = DrawLineTranslateCoordinates(offset,x,y,orthant);
/* Pixel zeichnen (wenn Koordinaten im Bild) */
if(coord.GetX() >= 0 && (unsigned)coord.GetX() < img->GetWidth()
&& coord.GetY() >= 0 && (unsigned)coord.GetY() < img->GetHeight()) {
img->SetPixel(coord.GetX(),coord.GetY(),0,GetColor().GetR());
img->SetPixel(coord.GetX(),coord.GetY(),1,GetColor().GetG());
img->SetPixel(coord.GetX(),coord.GetY(),2,GetColor().GetB());
}
/* Gemaess Bresenham-Algorithmus bestimmen, ob das Pixel rechts vom
* vorigen Pixel oder rechtsoben vom vorigen Pixel gesetzt werden muss */
if( e > 0 ) {
y++;
e += 2*(deltaY - deltaX);
} else {
e += 2*deltaY;
}
x++;
}
}
示例4: Contains
bool QuadTree::Contains(Coordinate point){
bool insideLeftBorder = (center.GetX()-radius) <= point.GetX();
bool insideRightBorder = (center.GetX()+radius) >= point.GetX();
bool insideTopBorder = (center.GetY()+radius) >= point.GetY();
bool insideBottomBorder = (center.GetY()-radius) <= point.GetY();
return insideLeftBorder && insideRightBorder && insideTopBorder && insideBottomBorder;
}
示例5: WorldToBlip
void Radar::WorldToBlip( Coordinate &w, Coordinate &b ) {
Player *p = Player::Instance();
Coordinate player = p->GetWorldPosition();
b.SetX( ( ( w.GetX() - player.GetX() ) / float(visibility) ) * ( RADAR_WIDTH / 2.0 ) );
b.SetY( ( ( w.GetY() - player.GetY() ) / float(visibility) ) * ( RADAR_HEIGHT / 2.0 ) );
}
示例6: InRange
/**\brief checks if a potential target is within targeting range
*
*/
bool AI::InRange(Coordinate a, Coordinate b){
//printf("InRange check\n");
int x=a.GetX() - b.GetX();
int y=a.GetY() - b.GetY();
//printf("finished InRange check\n");
return(x*x + y*y <=COMBAT_RANGE_SQUARED);
}
示例7: CheckMove
bool Bishop::CheckMove(Coordinate currentPosition, Coordinate movePosition, bool allowDoCornerStep){
if (abs(currentPosition.GetX() - movePosition.GetX()) == abs(currentPosition.GetY() - movePosition.GetY()))
return true;
return false;
}
示例8: Init
void PrimitiveBox::Init(const Coordinate &c1, const Coordinate &c2, const Color &c) {
points_.clear();
// construct rectangle
points_.push_back(c1);
points_.push_back(Coordinate(c1.GetX(), c2.GetY()));
points_.push_back(c2);
points_.push_back(Coordinate(c2.GetX(), c1.GetY()));
points_.push_back(c1);
SetColor(c);
}
示例9: GetFreemanCode
int Segmentation::GetFreemanCode(const int label, const Coordinate &firstPoint, std::vector<int> &freemanCode) {
int cx = firstPoint.GetX();
int cy = firstPoint.GetY();
const int width = labelImage_.GetWidth();
const int height = labelImage_.GetHeight();
const Color color = Color::red();
// initial direction is south
int cb = 6;
// continue until we're at the starting pixel again
while (true) {
int ck, dx, dy;
// test pixels from right to left in the general direction
for (ck = cb - 1; ck <= cb + 1; ck++) {
// translate freeman code to direction and apply it
get_fm(ck, dx, dy);
const int px = cx + dx;
const int py = cy + dy;
// ensure bounds
if (px >= 0 && py >= 0 && px <= width && py <= height) {
// if a pixel matches the label, move to that pixel and abort
if (labelImage_.GetPixel(px, py, 0) == label) {
cx = px; cy = py;
break;
}
}
}
ck = fmc(ck);
if (ck == cb || ck == fmc(cb + 1)) {
// matched pixel is forward or right, nothing needs to change
freemanCode.push_back(ck);
} else if (ck == fmc(cb - 1)) {
// pixel is left, turn left in addition to marking this pixel
cb -= 2;
freemanCode.push_back(ck);
} else {
// no pixel found, turn right
cb += 2;
}
cb = ((cb + 8) % 8);
// abort if we reached the start
if (cx == firstPoint.GetX() && cy == firstPoint.GetY())
break;
}
}
示例10: AdjustBoundaries
/** Adjust the Edges based on the locations of the populated QuadTrees
*/
void SpriteManager::AdjustBoundaries()
{
Coordinate c;
map<Coordinate,QuadTree*>::iterator iter;
northEdge = southEdge = eastEdge = westEdge = 0;
for ( iter = trees.begin(); iter != trees.end(); ++iter ) {
c = iter->first;
if( c.GetY() > northEdge) northEdge = c.GetY();
if( c.GetY() < southEdge) southEdge = c.GetY();
if( c.GetX() > eastEdge) eastEdge = c.GetX();
if( c.GetX() < westEdge) westEdge = c.GetX();
}
}
示例11: CheckMove
bool Pown::CheckMove(Coordinate currentPosition, Coordinate movePosition, bool allowDoCornerStep){
if (allowDoCornerStep)
{
if (abs(currentPosition.GetY() - movePosition.GetY()) == SQUARESIZE && abs(currentPosition.GetX() - movePosition.GetX()) == SQUARESIZE)
return true;
}
if (currentPosition.GetX() == movePosition.GetX())
{
return isMoved ? (abs(currentPosition.GetY() - movePosition.GetY()) == SQUARESIZE) : (abs(currentPosition.GetY() - movePosition.GetY()) <= 2 * SQUARESIZE);
}
return false;
}
示例12: Draw
void QuadTree::Draw(Coordinate root){
// The QuadTree is scaled so that it always fits on the screen.
float scale = (Video::GetHalfHeight() > Video::GetHalfWidth() ?
static_cast<float>(Video::GetHalfWidth()) : static_cast<float>(Video::GetHalfHeight()) -5);
float r = scale* radius / QUADRANTSIZE;
float x = (scale* static_cast<float>((center-root).GetX()) / QUADRANTSIZE)
+ static_cast<float>(Video::GetHalfWidth()) -r;
float y = (scale* static_cast<float>((center-root).GetY()) / QUADRANTSIZE)
+ static_cast<float>(Video::GetHalfHeight()) -r;
Video::DrawRect( static_cast<int>(x),static_cast<int>(y),
static_cast<int>(2*r),static_cast<int>(2*r), 0,255.f,0.f, .1f);
if(!isLeaf){ // Node
for(int t=0;t<4;t++){
if(NULL != (subtrees[t])) subtrees[t]->Draw(root);
}
} else { // Leaf
list<Sprite *>::iterator i;
for( i = objects->begin(); i != objects->end(); ++i ) {
Coordinate pos = (*i)->GetWorldPosition() - root;
int posx = static_cast<int>((scale* (float)pos.GetX() / QUADRANTSIZE) + (float)Video::GetHalfWidth());
int posy = static_cast<int>((scale* (float)pos.GetY() / QUADRANTSIZE) + (float)Video::GetHalfHeight());
Color col = (*i)->GetRadarColor();
// The 17 is here because it looks nice. I can't explain why.
Video::DrawCircle( posx, posy, static_cast<int>(17.f*(*i)->GetRadarSize()/scale),2, col.r,col.g,col.b );
}
}
}
示例13: DrawTarget
/**\brief Draws the target.
*/
void Hud::DrawTarget( SpriteManager* sprites ) {
Sprite* target = sprites->GetSpriteByID( targetID );
if(target != NULL) {
int edge = (target->GetImage())->GetWidth() / 6;
Coordinate targetScreenPosition = target->GetScreenPosition();
if(edge > 25) edge = 25;
int x = targetScreenPosition.GetX();
int y = targetScreenPosition.GetY();
int r = target->GetRadarSize();
Color c = target->GetRadarColor();
if( (Timer::GetTicks() - timeTargeted) < OPTION(Uint32, "options/timing/target-zoom")) {
r += Video::GetHalfHeight() - Video::GetHalfHeight()*(Timer::GetTicks()-timeTargeted)/OPTION(Uint32,"options/timing/target-zoom");
for( int i = 0; i < RETICLE_BLUR; i++ ) {
c = c * .9f;
edge += 3;
r *= 1.1f;
Video::DrawTarget(x,y,r,r,edge,c.r,c.g,c.b);
}
} else {
Video::DrawTarget(x,y,r,r,edge,c.r,c.g,c.b);
}
}
}
示例14: test_image
void test_image(const std::string name) {
std::cout << name.substr(name.find_last_of("/") + 1, std::string::npos) << ":" << std::endl;
Image image;
image.LoadPPM(name);
image.SetColorModel(ImageBase::cm_Grey);
const int label = 255;
Segmentation seg(image);
Coordinate center;
int area;
seg.GetCenterAndArea(label, center, area);
std::cout << " Object has its center at: " << center.GetX() << "," << center.GetY() << " with area: " << area << " pixel." << std::endl;
Coordinate topleft(seg.GetLabelTopLeft(label));
std::vector<int> fmc;
seg.GetFreemanCode(label, topleft, fmc);
const float circumference = seg.GetCircumference(fmc);
const float roundness = seg.GetRoundness(area, circumference);
std::cout << " Object has roundness of " << roundness << std::endl;
if (rint(roundness) >= 16) {
std::cout << " Object is a rectangle" << std::endl;
} else {
std::cout << " Object is a circle" << std::endl;
}
}
示例15: SubTreeThatContains
QuadPosition QuadTree::SubTreeThatContains(Coordinate point){
bool rightOfCenter = point.GetX() > center.GetX();
bool aboveCenter = point.GetY() > center.GetY();
int pos = (aboveCenter?0:2) | (rightOfCenter?1:0);
assert(this->Contains(point)); // Ensure that this point is in this region
return QuadPosition(pos);
}