本文整理汇总了C++中Coordinates类的典型用法代码示例。如果您正苦于以下问题:C++ Coordinates类的具体用法?C++ Coordinates怎么用?C++ Coordinates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Coordinates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayText
void Display::displayText(std::string text, Coordinates position){
const char* textTemp = text.c_str();
//Ne fonctionne pas tout le temps a verifier
al_draw_text(font, (al_map_rgba(255, 0, 0, 255)),
position.getX(), position.getY(), ALLEGRO_ALIGN_CENTRE, textTemp);
al_flip_display();
}
示例2: IMG_Load
void Scene::render(SDL_Surface * surface){
SDL_Surface *image = NULL;//, *rotation = NULL;
for (std::vector<Item>::iterator it=items.begin(); it!=items.end(); ++it){
Item varitem = *it;
//TODO: LOAD image
//image = IMG_Load(varitem.resource.rawPath.c_str());
image = IMG_Load("image.bmp");
SDL_Rect r;//,r2;
Coordinates newCoor = varitem.coordinates;
newCoor = newCoor.isoToScreen(
newCoor,
ApplicationPreferencesManager::getIntegerPreference("tileWidth", DEFAULT_WIDTH),
ApplicationPreferencesManager::getIntegerPreference("tileHeight", DEFAULT_WIDTH)
);
r.x = newCoor.x;
r.y = newCoor.y;
r.w = ApplicationPreferencesManager::getIntegerPreference("tileWidth", DEFAULT_WIDTH);
r.h = ApplicationPreferencesManager::getIntegerPreference("tileHeight", DEFAULT_WIDTH);
//r2 = r;
//r2.w = sqrt(r.w*r.w+r.h*r.h)/2.0;
//r2.h = r2.w;
image->w = r.w;
image->h = r.h;
//rotation = rotozoomSurface(image, 45, 1.0, 1);
//rotation->w = r.w;
//rotation->h = r.h;
//SDL_BlitSurface(rotation, NULL, surface, &r);
SDL_BlitSurface(image, NULL, surface, &r);
//SDL_FreeSurface(rotation);
SDL_FreeSurface(image);
}
}
示例3: copyCoordinates
void copyCoordinates(Coordinates& dst, const Coordinates& src)
{
assert(dst.size() >= src.size());
for (Coordinates::size_type i = 0; i < src.size(); ++i) {
dst[i] = src[i];
}
}
示例4: Coordinates
//------------------------------------------------------------------------------
bool SVGLine::resize()
{
signed int x, y;
std::string str_value;
Coordinates *coord = new Coordinates(0,0);
std::cout << "id: " << id_ << std::endl;
std::cout << "x2: " << coordinates_.back().getX() << std::endl;
std::cout << "y2: " << coordinates_.back().getY() << std::endl;
coordinates_.erase(coordinates_.begin()+1);
while(true)
{
if(ui_->getParam(" x2? ", false, false, x, str_value, true))
break;
}
coord->setX(x);
while(true)
{
if(ui_->getParam(" y2? ", false, false, y, str_value, true))
break;
}
coord->setY(y);
coordinates_.push_back(*coord);
delete coord;
return true;
}
示例5: median3x3
SimpleTensor<T> median3x3(const SimpleTensor<T> &src, BorderMode border_mode, T constant_border_value)
{
SimpleTensor<T> dst(src.shape(), src.data_type());
const int size_tot_filter = filter_size * filter_size;
for(int src_idx = 0; src_idx < src.num_elements(); ++src_idx)
{
std::array<T, size_tot_filter> filter_elems = { { 0 } };
Coordinates id = index2coord(src.shape(), src_idx);
const int x = id.x();
const int y = id.y();
for(int j = y - static_cast<int>(border_size.top), index = 0; j <= y + static_cast<int>(border_size.bottom); ++j)
{
for(int i = x - static_cast<int>(border_size.left); i <= x + static_cast<int>(border_size.right); ++i, ++index)
{
id.set(0, i);
id.set(1, j);
filter_elems[index] = tensor_elem_at(src, id, border_mode, constant_border_value);
}
}
std::sort(filter_elems.begin(), filter_elems.end());
dst[src_idx] = filter_elems[size_tot_filter / 2];
}
return dst;
}
示例6: impl
JSValue JSCoordinates::speed(ExecState* exec) const
{
Coordinates* imp = impl();
if (!imp->canProvideSpeed())
return jsNull();
return jsNumber(exec, imp->speed());
}
示例7: LocationListener
bool
LocationMonitorApp::OnAppInitializing(AppRegistry& appRegistry)
{
// TODO:
// Initialize App specific data, and add your initialization code here
// The App's permanent data and context can be obtained from the appRegistry.
//
// If this method is successful, return true; otherwise, return false.
// If this method returns false, the App will be terminated.
LocationListener* pListener = null;
pListener = new LocationListener();
LocationCriteria criteria;
criteria.SetAccuracy(LOC_ACCURACY_HUNDRED_METERS);
LocationProvider* pLocProvider = new LocationProvider();
pLocProvider->Construct(criteria, *pListener);
//bool awake = true;
//pLocProvider->KeepLocationUpdateAwake(awake);
Coordinates coord;
coord.Set(27.0, 125.0, 0.0); //result Set (double latitude, double longitude, double altitude)
RegionId regionId;
pLocProvider->AddMonitoringRegion(coord, 100, regionId);
MockLocationListener* timer = new MockLocationListener();
timer->StartApp();
return true;
}
示例8: Entity
Flag::Flag(Entity* entity) :
Entity(entity) {
Vector3* pos = entity->getCurrentPos();
this->currentPos = new Vector3(pos->getX(), pos->getY(), pos->getZ());
Coordinates coordin = entity->getCoordinates();
this->coord = new Coordinates(coordin.getCol(), coordin.getRow());
Base base = entity->getBase();
Base* newBase = new Base(base);
this->base = newBase;
this->name = entity->getName();
this->currentTile = NULL;
this->team = entity->getTeam();
this->killedBy = entity->getKilledBy();
this->damageBuffer = 0;
this->magic = entity->getMagic();
this->walkable = entity->isWalkable();
this->attackable = entity->isAttackable();
this->hideInFog = entity->getHideInFog();
this->shield = 0;
this->removeFromGame = false;
player = "";
classname = "Flag";
life = 30;
attackable = true;
}
示例9: result
Coordinates Coordinates::
operator+(const Coordinates &other) const
{
Coordinates result(*this);
std::copy(other.begin(), other.end(), std::back_inserter(result));
return result;
}//operator+
示例10: findTeleportLocation
//------------------------------------------------------------------------------
void Game::findTeleportLocation(const string teleport_letter,
const Coordinates& position, Coordinates& teleport_exit)
{
int portal_x=0, portal_y=0;
for (std::size_t y = 0; y < board_->size(); y++)
{
for (std::size_t x = 0; x < board_->at(y).size(); x++)
{
string symbol = board_->at(y).at(x)->getFieldSymbol(Field::FOR_GAME);
// If the momentary field in this loop is not the one the player wants to
// enter and if it has the same portal letter as the one he wants to enter
// it must be the corresponding portal of that field.
std::size_t player_x = position.getX();
std::size_t player_y = position.getY();
if (((x != player_x) || (y != player_y))
&& symbol == teleport_letter)
{
portal_x = static_cast<int>(x);
portal_y = static_cast<int>(y);
}
}
}
teleport_exit.setX(portal_x);
teleport_exit.setY(portal_y);
}
示例11: init
LinearRing::LinearRing()
{
init();
Coordinates* tmp = new Coordinates();
tmp->addCoordinate(0.0, 0.0, 0.0);
AddChild(tmp);
}
示例12: to_chunk_coordinates
const Coordinates to_chunk_coordinates(const Coordinates& c)
{
int x = ((int)std::floor(c.x() / (double)NM_CHUNK_SIZE));
int y = ((int)std::floor(c.y() / (double)NM_CHUNK_SIZE));
return {x, y};
}
示例13: giveMeWords
std::set< std::string > BoggleSolver::giveMeWords(std::string base, Coordinates start, std::set< Coordinates > alreadyUsed) const
{
std::set< std::string > result;
std::set< std::string > otherResult;
base+=getLetter(start.getX(),start.getY());
alreadyUsed.insert(start);
if(base.size()>=MIN_WORD_LENGTH )
{
//Attention, upper != lower+1
std::string upperBound = dictionnary.getUpperBound(base);
if(dictionnary.isValid(base))
result.insert(base);
//Optimisation : si on ne trouve pas base dans le début de upper bound, on peut arreter
if(upperBound.compare(0,base.size(),base)!=0)
return result;
}
std::vector<Coordinates> adj = start.getAdjacent(gridSize-1,gridSize-1);
for(std::vector<Coordinates >::const_iterator it = adj.begin(); it != adj.end();++it)
{
if(alreadyUsed.find(*it)==alreadyUsed.end())
{
otherResult = giveMeWords(base,*it,alreadyUsed);
std::set_union(result.begin(), result.end(), otherResult.begin(), otherResult.end(), std::inserter(result,result.end()));
}
}
return result;
}
示例14: process
/// For algorithm details, see http://wiki.openstreetmap.org/wiki/Relation:multipolygon/Algorithm
void MultipolygonProcessor::process() {
bool allClosed = true;
// NOTE do not count multipolygon tag itself
bool hasNoTags = relation_.tags.size() < 2;
Ints outerIndecies;
Ints innerIndecies;
CoordinateSequences sequences;
for (const auto &member : members_) {
if (member.type!="w")
continue;
Coordinates coordinates;
auto wayPair = context_.wayMap.find(member.refId);
if (wayPair!=context_.wayMap.end()) {
coordinates = wayPair->second->coordinates;
} else {
auto areaPair = context_.areaMap.find(member.refId);
if (areaPair!=context_.areaMap.end()) {
coordinates = areaPair->second->coordinates;
// NOTE make coordinates to be closed ring
coordinates.push_back(coordinates[0]);
// NOTE merge tags to relation
// hasNoTags prevents the case where relation has members with their own tags
// which should be processed independently (geometry reusage)
if (member.role=="outer" && hasNoTags)
mergeTags(areaPair->second->tags);
} else {
auto relationPair = context_.relationMap.find(member.refId);
if (relationPair==context_.relationMap.end())
return; // NOTE cannot fill relation: incomplete data
resolve_(*relationPair->second);
}
}
if (coordinates.empty())
continue;
if (member.role=="outer")
outerIndecies.push_back(static_cast<int>(sequences.size()));
else if (member.role=="inner")
innerIndecies.push_back(static_cast<int>(sequences.size()));
else
continue;
auto sequence = std::make_shared<CoordinateSequence>(member.refId, coordinates);
if (!sequence->isClosed())
allClosed = false;
sequences.push_back(sequence);
}
if (outerIndecies.size()==1 && allClosed)
simpleCase(sequences, outerIndecies, innerIndecies);
else
complexCase(sequences);
}
示例15: position
Coordinates TCXParser::position()
{
Coordinates pos;
qreal val;
bool res;
while (_reader.readNextStartElement()) {
if (_reader.name() == "LatitudeDegrees") {
val = _reader.readElementText().toDouble(&res);
if (!res || (val < -90.0 || val > 90.0))
_reader.raiseError("Invalid LatitudeDegrees");
else
pos.setLat(val);
} else if (_reader.name() == "LongitudeDegrees") {
val = _reader.readElementText().toDouble(&res);
if (!res || (val < -180.0 || val > 180.0))
_reader.raiseError("Invalid LongitudeDegrees");
else
pos.setLon(val);
} else
_reader.skipCurrentElement();
}
return pos;
}