本文整理汇总了C++中Coord类的典型用法代码示例。如果您正苦于以下问题:C++ Coord类的具体用法?C++ Coord怎么用?C++ Coord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Coord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSetDegrees
void testSetDegrees()
{
cout << "\n***** TestCoord06 *****\n";
Coord coord;
coord.setDeg(90);
coord.display();
}
示例2: camera2D
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;
}
示例3: testSetZpoint
void testSetZpoint()
{
cout << "\n***** TestCoord05 *****\n";
Coord coord;
coord.setZpoint(2);
coord.display();
}
示例4: matrix
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);
}
}
}
示例5: op
// 아바타의 위치를 기반으로 최종 목표지점의 maptile에 walk를 할 수 있도록 한다.
bool GameMap::walk(AvatarPtr& avatar, Direction direction, int distance)
{
// 아바타가 존재하면서 자신의 좌표목록에 등록되어 있는지 검사한다.
if (!avatar || (avatar_position.find(avatar) == avatar_position.end()))
return false;
// 제대로 된 거리인지 검사한다.
if (distance <= 0)
return false;
// 아바타에 필요한 양의 SP가 있는지 검사한다.
if (avatar->getCurrentSP() < SP_WALK * distance)
return false;
// 목적지의 좌표를 구해서 이동할 수 있는 좌표인지 검사한다.
Coord op(avatar_position[avatar]);
Coord dp = op;
for(int i = 0; i < distance; i++)
dp.move(direction);
if(!isInnerCoord(dp))
return false;
// TODO 2.0+ : 목적지로 가는 중간에 장애물이 있는 타일이 존재하는지 검사한다.
// 올바르게 옮기기 위한 검사가 모두 끝났다.
// 이제 아바타를 옮기고, 자신의 좌표목록도 새로운 값으로 고친다.
if(!::AIOnly::moveAvatar(_map[op.y][op.x], _map[dp.y][dp.x]))
return false;
avatar_position[avatar].x = dp.x;
avatar_position[avatar].y = dp.y;
return true;
}
示例6: switch
void UIEntity::drawShoot(Sea::Player player, const Coord& c, const HitInfo& info)
{
switch (info.type) {
case HitInfo::HIT:
m_seaview->hit(player, c);
// registerHit(player, c);
break;
case HitInfo::MISS:
m_seaview->miss(player, c);
// registerMiss(player, c);
break;
default:
return;
}
if (info.shipDestroyed) {
Coord shipPos = info.shipPos;
if (shipPos.valid()) {
// show destroyed opponent ship
if (player != m_player) {
m_seaview->add(player, info.shipDestroyed);
}
m_seaview->sink(player, info.shipDestroyed);
}
}
}
示例7:
Coord Coord::operator+ (const Coord &rhs) const
{
Coord res;
for (size_t i = 0; i < Coord::mDefDims; ++i)
res.SetCoord(i, this->GetCoord(i) + rhs.GetCoord(i));
return res;
}
示例8: apply
/** トラック間のモーションブレンドをした値を適用
*
* @param skl モーションを適用するSkelton
* @param initial_skl 初期値を持っているSkelton
* @author SAM (T&GG, Org.)<[email protected]>
* @date 2004/10/05 0:18:41
* Copyright (C) 2001,2002,2003,2004 SAM (T&GG, Org.). All rights reserved.
*/
void MotionMixer::apply(Skeleton &skl, const Skeleton &initial_skl) const
{
for(Skeleton::NodeIndex::iterator i = skl.index.begin(); i != skl.index.end(); ++i) {
float weight_sum = 0;
bool ok = false;
for(MotionTrackVector::const_iterator j = tracks_.begin(); j != tracks_.end(); ++j) {
if(j->setWork(Coord(reinterpret_cast<Skeleton::NodeType *>(initial_skl[i->first])->val.lcm()), i->first.c_str())) {
weight_sum += j->weight();
ok = true;
}
}
if(ok) {
bool first = true;
Coord coord;
for(MotionTrackVector::const_iterator j = tracks_.begin(); j != tracks_.end(); ++j) {
if(j->work().type != CoordUnion::TYPE_NONE) {
if(first) {
coord = j->work().coord()*(j->weight()/weight_sum);
first = false;
}
else coord += j->work().coord()*(j->weight()/weight_sum);
}
}
reinterpret_cast<Skeleton::NodeType *>(i->second)->val.getLCM() = coord.toMatrix();
}
}
}
示例9: initCellValue
/**
* range x=[0;1] y[0;1]
*
* set boundary to sin(PI*x)*sinh(PI*y),
* centerpoints to 0
*/
inline double initCellValue(Coord<2> c, Coord<2> gridDimensions){
double xPos = ((double)c.x()) / gridDimensions.x();
double yPos = ((double)c.y()) / gridDimensions.y();
return sin(M_PI*xPos)*sinh(M_PI*yPos);
}
示例10: testClass
// TEST class constructor
void testClass()
{
cout << "\n***** TestCoord01 *****\n";
Coord coord;
Coord();
coord.display();
}
示例11: labelToDraw
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);
}
示例12: stepFinished
void stepFinished(const WriterGridType& grid, unsigned step, WriterEvent event)
{
TracingWriter<Cell>::stepFinished(grid, step, event);
if ((step % ParallelWriter<Cell>::period) != 0) {
return;
}
int numAnts = 0;
int numFood = 0;
Coord<2> dim = grid.dimensions();
for(int y = 0; y < dim.y(); ++y) {
for(int x = 0; x < dim.x(); ++x) {
if (grid.get(Coord<2>(x, y)).isAnt()) {
++numAnts;
}
if (grid.get(Coord<2>(x, y)).containsFood()) {
++numFood;
}
}
}
std::cout << " numAnts: " << numAnts << "\n"
<< " numFood: " << numFood << "\n";
}
示例13: log
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);
}
示例14: if
void ArbitrationWidget::updateCoordText(const Coord &iNewCoord)
{
if (iNewCoord.isValid() && lineEditCoords->text() != qfw(iNewCoord.toString()))
lineEditCoords->setText(qfw(iNewCoord.toString()));
else if (!iNewCoord.isValid() && lineEditCoords->hasAcceptableInput())
lineEditCoords->setText("");
lineEditWord->setFocus();
}
示例15: bruteAlgorithm
void bruteAlgorithm(){
string space = " ";
string input = "";
bool isDuplicate = false;
string xCoord, yCoord;
vector<Coord> myCoord;
Coord tempCoord;
Coord finalCoord;
int i = 0, b = 0;
while (getline(cin, input)){
if (input == "") continue;
if (input.find_first_not_of("-1234567890. ", 0) != std::string::npos) continue;
if (input.find(space, 0) == std::string::npos) continue;
size_t firstSpace = input.find(space);
xCoord = input.substr(0, firstSpace);
yCoord = input.substr(input.find_first_not_of(" ", xCoord.length() + 1));
if (yCoord.find(space) != std::string::npos){
int a = yCoord.find(space);
if (yCoord.find_first_not_of(" ", a + 1) != std::string::npos){
continue;
}
}
tempCoord.x = stod(xCoord, NULL);
tempCoord.y = stod(yCoord, NULL);
for (std::vector<Coord>::iterator it = myCoord.begin(); it != myCoord.end(); ++it){
if (isEqual(it->x, tempCoord.x) && isEqual(it->y, tempCoord.y)){
isDuplicate = true;
}
}
if (isDuplicate == false){
myCoord.push_back(tempCoord);
i++;
} else{
isDuplicate = false;
}
}
if (myCoord.size() < 2){
cout << "You must enter 2 or more data points." << endl;
return;
}
double tempDistance;
for (int a = 0; a < i; a++){
for (int b = 0; b < i; b++){
if ( a != b) {
tempDistance = calcDistance(myCoord[a], myCoord[b]);
if (tempDistance < finalCoord.distance){
finalCoord.setCoord(myCoord[a].x, myCoord[a].y);
finalCoord.setClosestPair(myCoord[b].x, myCoord[b].y, tempDistance);
}
}
}
}
printf("%.7f\n(%.7f, %.7f) (%.7f, %.7f)\n",finalCoord.distance, finalCoord.x, finalCoord.y, finalCoord.x1, finalCoord.y1);
}