Local void checkLabel(Char *w) { voice_index j, FORLIM; Char STR1[256], STR2[256]; FORLIM = nvoices; for (j = 0; j <= FORLIM - 1; j++) { if (!strcmp(w, voice_label[j])) { sprintf(STR2, "Voice label %s not unique", w); warning(STR2, print); return; } } if (strlen(w) > 2) return; if (pos1(w[0], "CLU") > 0) { if (strlen(w) > 1) { if (pos1(w[1], "123456789") == 0) return; } } else if (pos1(w[0], "123456789") == 0) return; sprintf(STR1, "Voice label %s conflicts with reserved label", w); error(STR1, print); }
Static void textTranslate(Char *uptext, Char *font) { short k; Char STR1[256], STR2[256], STR3[256], STR4[256]; short FORLIM; if (*uptext == '\0') return; do { k = pos1('%', uptext); if (k > 0) { sprintf(STR4, "%s{\\mtxFlat}%s", substr_(STR1, uptext, 1, k - 1), substr_(STR3, uptext, k + 1, strlen(uptext) - k)); strcpy(uptext, STR4); } } while (k != 0); do { k = pos1('#', uptext); if (k > 0) { sprintf(STR2, "%s{\\mtxSharp}%s", substr_(STR1, uptext, 1, k - 1), substr_(STR4, uptext, k + 1, strlen(uptext) - k)); strcpy(uptext, STR2); } } while (k != 0); switch (uptext[0]) { case '<': if (!strcmp(uptext, "<")) strcpy(uptext, "\\mtxIcresc"); else if (!strcmp(uptext, "<.")) strcpy(uptext, "\\mtxTcresc"); else { predelete(uptext, 1); sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext)); } break; case '>': if (!strcmp(uptext, ">")) strcpy(uptext, "\\mtxIdecresc"); else if (!strcmp(uptext, ">.")) strcpy(uptext, "\\mtxTdecresc"); else { predelete(uptext, 1); sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext)); } break; default: FORLIM = strlen(uptext); for (k = 0; k <= FORLIM - 1; k++) { if (pos1(uptext[k], "mpfzrs~") == 0) return; } break; } strcpy(font, "\\mtxPF"); }
bool DemoKeeper::demoLoop( const Ogre::FrameEvent& evt ) { mWorld->markForWrite(); // //running demo loop accordingly // if (Keyframe_demoRunning) { hkVector4 pos; hkQuaternion rot; getKeyframePositionAndRotation(m_time + evt.timeSinceLastFrame, pos, rot); hkpKeyFrameUtility::applyHardKeyFrame(pos, rot, 1.0f /evt.timeSinceLastFrame, m_keyframedBody); m_time += evt.timeSinceLastFrame; } else if (binaryaction_demoRunning) { hkVector4 pos1 = m_boxRigidBody1->getPosition(); hkVector4 pos2 = m_boxRigidBody2->getPosition(); hkVector4 lenVec; lenVec.setSub4(pos1, pos2); manual_spring = mSceneMgr->createManualObject(); manual_spring->setQueryFlags(0); manual_spring->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST); manual_spring->position(pos1(0),pos1(1),pos1(2)); if (lenVec.length3() > m_springAction->getRestLength()) { // Line is red if the spring is stretched. manual_spring->colour(1,0,0); } else { // Line is blue is spring is at rest or compressed. manual_spring->colour(0,0,1); } manual_spring->position(pos2(0),pos2(1),pos2(2)); manual_spring->end(); springNode->detachAllObjects(); springNode->attachObject(manual_spring); } mWorld->unmarkForWrite(); return true; }
void setOnly(Char *line_) { Char line[256]; short num, num1, num2, l; Char s[256]; Char STR1[256]; strcpy(line, line_); if (*line == '\0') return; if (startsWithIgnoreCase(line, "only")) GetNextWord(STR1, line, colon_, dummy); for (l = 0; l <= lines_in_paragraph - 1; l++) omit_line[l] = true; do { GetNextWord(s, line, blank_, comma_); if (*s == '\0') return; curtail(s, comma_); if (pos1('-', s) == 0) { getNum(s, &num); if (num > 0 && num <= lines_in_paragraph) omit_line[num-1] = false; else warning("Invalid line number in Only: is skipped", print); } else { getTwoNums(s, &num1, &num2); if (num1 > 0 && num2 <= lines_in_paragraph) { for (num = num1 - 1; num <= num2 - 1; num++) omit_line[num] = false; } else warning("Invalid line range in Only: is skipped", print); } } while (true); }
void AirController::doWork() { std::list<Flight*> flights = Airport::getInstance()->getFlights(); std::list<Flight*>::iterator it; Position pos0(3500.0, 0.0, 100.0); Position pos1(1500.0, 0.0, 50.0); Position pos2(200.0, 0.0, 25.0); Position pos3(-750.0, 0.0, 25.0); Route r0, r1, r2, r3; r0.pos = pos0; r0.speed = 500.0; r1.pos = pos1; r1.speed = 100.0; r2.pos = pos2; r2.speed = 19.0; r3.pos = pos3; r3.speed = 15.0; for(it = flights.begin(); it!=flights.end(); ++it) { if((*it)->getRoute()->empty()) { (*it)->getRoute()->push_back(r3); (*it)->getRoute()->push_front(r2); (*it)->getRoute()->push_front(r1); (*it)->getRoute()->push_front(r0); } } }
/** * Whether going from one tile to another blocks movement. * @param startTile * @param endTile * @param direction * @return true/false */ bool Pathfinding::isBlocked(Tile *startTile, Tile *endTile, const int direction) { // check if the difference in height between start and destination is not too high // so we can not jump to the highest part of the stairs from the floor // stairs terrainlevel goes typically -8 -16 (2 steps) or -4 -12 -20 (3 steps) // this "maximum jump height" is therefore set to 8 static const Position oneTileNorth = Position(0, -1, 0); static const Position oneTileEast = Position(1, 0, 0); static const Position oneTileSouth = Position(0, 1, 0); static const Position oneTileWest = Position(-1, 0, 0); Position pos1 (startTile->getPosition()); switch(direction) { case 0: // north if (isBlocked(startTile, MapData::O_NORTHWALL)) return true; break; case 1: // north east if (isBlocked(startTile,MapData::O_NORTHWALL)) return true; if (isBlocked(endTile,MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL)) return true; break; case 2: // east if (isBlocked(endTile,MapData::O_WESTWALL)) return true; break; case 3: // south east if (isBlocked(endTile,MapData::O_WESTWALL)) return true; if (isBlocked(endTile,MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileEast),MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileSouth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileEast),O_BIGWALL)) return true; break; case 4: // south if (isBlocked(endTile,MapData::O_NORTHWALL)) return true; break; case 5: // south west if (isBlocked(endTile,MapData::O_NORTHWALL)) return true; if (isBlocked(startTile,MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileSouth),MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileSouth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileWest),O_BIGWALL)) return true; break; case 6: // west if (isBlocked(startTile,MapData::O_WESTWALL)) return true; break; case 7: // north west if (isBlocked(startTile,MapData::O_WESTWALL)) return true; if (isBlocked(startTile,MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileNorth),MapData::O_WESTWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileWest),MapData::O_NORTHWALL)) return true; if (isBlocked(_save->getTile(pos1 + oneTileNorth),O_BIGWALL) && isBlocked(_save->getTile(pos1 + oneTileWest),O_BIGWALL)) return true; break; } return false; }
bool WindowsManager::addSquareFace (const char* faceNameCorba, const value_type* posCorba1, const value_type* posCorba2, const value_type* posCorba3, const value_type* posCorba4, const value_type* colorCorba) { std::string faceName (faceNameCorba); if (nodes_.find (faceName) != nodes_.end ()) { std::cout << "You need to chose an other name, \"" << faceName << "\" already exist." << std::endl; return false; } else { mtx_.lock(); osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]); osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]); osgVector3 pos3 (posCorba3[0], posCorba3[1], posCorba3[2]); osgVector3 pos4 (posCorba4[0], posCorba4[1], posCorba4[2]); LeafNodeFacePtr_t face = LeafNodeFace::create (faceName, pos1, pos2, pos3, pos3, getColor (colorCorba)); WindowsManager::initParent (faceName, face); addNode (faceName, face); mtx_.unlock(); return true; } }
float CRole::getDistanceSqInGrid(IGridRole* role) { Point p1 = getPositionInGrid(); Point p2 = role->getPositionInGrid(); int i,j,m,n; float smallest = FLT_MAX; for (i = 0; i < getGridWidth(); ++i) { for (j = 0; j < getGridHeight(); ++j) { Point pos1(p1.x + i, p1.y + j); for (m = 0; m < role->getGridWidth(); ++m) { for (n = 0; n < role->getGridHeight(); ++n) { Point pos2(p2.x + m, p2.y + n); float dist = pos1.getDistanceSq(pos2); if (dist < smallest) { // CCLOG("(%f,%f --> %f, %f) %f", pos1.x, pos1.y, pos2.x, pos2.y, dist); smallest = dist; } } } } } return smallest; }
void CollisionSystem::ResolveCollision(Actor* actor1, Actor* actor2) { const float PUSH_AMOUNT = 0.65f; float radius1 = actor1->GetRadius(); float radius2 = actor2->GetRadius(); Vector2Df pos1(actor1->Get2DPos()); Vector2Df pos2(actor2->Get2DPos()); Vector2Df dir(pos1 - pos2); float sqrdDist = dir.SquaredLength(); float radiusSqrd = radius1 + radius2; radiusSqrd *= radiusSqrd; if(sqrdDist < radiusSqrd) { float length = dir.Length(); float mult = abs(1.0f - length / (radius1 + radius2)); pos1 += dir * PUSH_AMOUNT * mult; if(actor1->CanBeMoved()) actor1->SetPosition(Vector3Df(pos1.x_, 0.0f, pos1.y_)); pos2 += dir * -PUSH_AMOUNT * mult; if(actor2->CanBeMoved()) actor2->SetPosition(Vector3Df(pos2.x_, 0.0f, pos2.y_)); actor1->Collided(actor2); actor2->Collided(actor1); } }
// --- void Entity_4::drawOn (QGAMES::Screen* s, const QGAMES::Position& p) { QGAMES::ArtistInATiledMap::drawOn (s, p); #ifndef NDEBUG s -> drawRectangle (collisionZone (), QGAMES::Color (120,120,120,255)); int ePosX, ePosY, ntW, ntH; QGAMES::bdata m = (QGAMES::bdata) 0.0; QGAMES::Vector pv (__BD 0, __BD 0, __BD 0); adjustRelevants (m, pv); tilesOcuppied (ePosX, ePosY, ntW, ntH, m, pv); int tWidth = (__TM map ()) -> tileWidth (); int tHeight = (__TM map ()) -> tileHeight (); int mWidth = map () -> width () / tWidth; int mHeight = map () -> height () / tHeight; int nE = ePosY * mWidth + ePosX; for (int i = 0; i < ntH; i++) { for (int j = 0; j < ntW; j++) { int iPos = nE + (i * mWidth + j); QGAMES::Position pos1 (__BD ((iPos % mWidth) * tWidth), __BD ((iPos / mWidth) * tHeight), __BD 0); QGAMES::Position pos2 = pos1 + QGAMES::Vector (__BD tWidth, __BD tHeight, __BD 0); s -> drawRectangle (QGAMES::Rectangle (pos1, pos2), QGAMES::Color (255,255,0,255)); } } #endif }
Local void processUsual(struct LOC_processLine *LINK) { if (hasVerseNumber(LINK->voice)) strcat(LINK->pretex, "\\mtxVerse"); LINK->l = pos1(multi_group, LINK->note); if (LINK->l > 0) scan1(LINK->note, LINK->l + 1, &LINK->nmulti); activateBeamsAndSlurs(LINK->voice); LINK->in_group = false; if (LINK->ngrace > 0) { LINK->in_group = true; LINK->ngrace--; } else { if (LINK->nmulti > 0) { LINK->in_group = true; LINK->nmulti--; } } checkOctave(LINK->voice, LINK->note); renewPitch(LINK->voice, LINK->note); if (!LINK->in_group) { resetDuration(LINK->voice, durationCode(LINK->note)); markDebeamed(LINK->voice, LINK->note); } lookahead(LINK); getSyllable(LINK->voice, LINK->pretex); addUptext(LINK->voice, &LINK->no_uptext, LINK->pretex); addChords(LINK); }
dReal ServoMotor::getTorque() { // code from Jeff Shim osg::Vec3 torque1(fback_.t1[0], fback_.t1[1], fback_.t1[2] ); osg::Vec3 torque2(fback_.t2[0], fback_.t2[1], fback_.t2[2] ); osg::Vec3 force1(fback_.f1[0], fback_.f1[1], fback_.f1[2] ); osg::Vec3 force2(fback_.f2[0], fback_.f2[1], fback_.f2[2] ); const double* p1 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),0) ); const double* p2 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),1) ); osg::Vec3 pos1(p1[0], p1[1], p1[2]); osg::Vec3 pos2(p2[0], p2[1], p2[2]); dVector3 odeAnchor; dJointGetHingeAnchor ( joint_->getJoint(), odeAnchor ); osg::Vec3 anchor(odeAnchor[0], odeAnchor[1], odeAnchor[2]); osg::Vec3 ftorque1 = torque1 - (force1^(pos1-anchor));// torq by motor = total torq - constraint torq osg::Vec3 ftorque2 = torque2 - (force2^(pos2-anchor));// opposite direction - use if this is necessary dVector3 odeAxis; dJointGetHingeAxis ( joint_->getJoint(), odeAxis); osg::Vec3 axis(odeAxis[0], odeAxis[1], odeAxis[2] ); axis.normalize(); double torque = ftorque1 * axis; //printf ("torque: % 1.10f\n", torque); return torque; }
Local void countIt(struct LOC_scanMusic *LINK) { struct LOC_countIt V; V.LINK = LINK; if (LINK->ngrace > 0) { LINK->ngrace--; return; } if (LINK->nmulti > 0) { decmulti(LINK); return; } if (LINK->count % 3 != 0 && (LINK->note[0] != rest && note_attrib[LINK->voice-1]['d' - 'a'] || LINK->note[0] == rest && rest_attrib[LINK->voice-1]['d' - 'a'])) LINK->count += LINK->count / 2; /* p2c: mtx.pas, line 150: * Note: Using % for possibly-negative arguments [317] */ incbar(LINK->count, &V); LINK->l = pos1(multi_group, LINK->note); if (LINK->l <= 0) return; predelete(LINK->note, LINK->l); getNum(LINK->note, &LINK->nmulti); decmulti(LINK); }
Static void checkSticky(Char *note, boolean *attrib) { short i = 2; short l; Char c; Char a[256]; if (*note == '\0') return; l = strlen(note); while (i <= l) { c = note[i-1]; if (islower(c)) { if (i < l && note[i] == ':') { delete1(note, i + 1); l--; attrib[c - 'a'] = !attrib[c - 'a']; } else attrib[c - 'a'] = false; } i++; } attribs(a, note); for (c = 'z'; c >= 'a'; c--) { if (attrib[c - 'a'] && pos1(c, a) == 0) insertChar(c, note, 3); } }
void DrawVertexList(const VertexBuffer& vertexBuffer) { std::vector<VertexList*>::const_iterator bufferIt = vertexBuffer.lists.begin(); std::vector<VertexList*>::const_iterator bufferItEnd = vertexBuffer.lists.end(); for(; bufferIt != bufferItEnd; bufferIt++) { const VertexList& vertexList = **bufferIt; Graphic& graphic = Graphic::Instance(); int indexCount = (int)vertexList.indices.size(); for(int i = 0; ((i + 1) * 3) <= indexCount; i++) { int idx0 = vertexList.indices[i * 3]; int idx1 = vertexList.indices[(i * 3) + 1]; int idx2 = vertexList.indices[(i * 3) + 2]; Vector2 pos0(vertexList.vertices[idx0].xyz.x, vertexList.vertices[idx0].xyz.y); Vector2 pos1(vertexList.vertices[idx1].xyz.x, vertexList.vertices[idx1].xyz.y); Vector2 pos2(vertexList.vertices[idx2].xyz.x, vertexList.vertices[idx2].xyz.y); graphic.DrawLine(pos0, pos1, 0xFF0000FF); graphic.DrawLine(pos1, pos2, 0xFF0000FF); graphic.DrawLine(pos2, pos0, 0xFF0000FF); } } }
QRectF Dynamic::drag(EditData* ed) { QRectF f = Element::drag(ed); // // move anchor // Qt::KeyboardModifiers km = qApp->keyboardModifiers(); if (km != (Qt::ShiftModifier | Qt::ControlModifier)) { int si; Segment* seg = 0; if (score()->pos2measure(ed->pos, &si, 0, &seg, 0) == nullptr) return f; if (seg && (seg != segment() || staffIdx() != si)) { QPointF pos1(canvasPos()); score()->undo(new ChangeParent(this, seg, si)); setUserOff(QPointF()); layout(); QPointF pos2(canvasPos()); setUserOff(pos1 - pos2); ed->startMove = pos2; } } return f; }
void test_panning_sine_mix() { Sine vox1(431); // sine osc Sine pos1(0.5); // sine LFO for panner // Panner pan1(&vox1, -1.0, 0.1); // scaling panner Panner pan1(vox1, pos1, 0.1); // scaling panner Sine vox2(170); Sine pos2(0.3); // Panner pan2(&vox2, -0.3, 0.1); Panner pan2(vox2, pos2, 0.1); Sine vox3(267); Sine pos3(0.4); // Panner pan3(&vox3, 0.3, 0.1); Panner pan3(vox3, pos3, 0.1); Sine vox4(224); Sine pos4(0.7); // Panner pan4(&vox4, 1.0, 0.1); Panner pan4(vox4, pos4, 0.1); Mixer mix(2); // create a stereo mixer mix.add_input(pan1); // add the panners to the mixer mix.add_input(pan2); mix.add_input(pan3); mix.add_input(pan4); logMsg("playing panning mix of 4 sines..."); run_test(mix, 9); logMsg("mix done."); }
void CardContainer::fillCards(const QList<int> &card_ids, const QList<int> &disabled_ids) { QList<CardItem *> card_items; if (card_ids.isEmpty() && items.isEmpty()) return; else if (card_ids.isEmpty() && !items.isEmpty()) { card_items = items; items.clear(); } else if (!items.isEmpty()) { retained_stack.push(retained()); items_stack.push(items); foreach (CardItem *item, items) item->hide(); items.clear(); } close_button->hide(); if (card_items.isEmpty()) card_items = _createCards(card_ids); int card_width = G_COMMON_LAYOUT.m_cardNormalWidth; QPointF pos1(30 + card_width / 2, 40 + G_COMMON_LAYOUT.m_cardNormalHeight / 2); QPointF pos2(30 + card_width / 2, 184 + G_COMMON_LAYOUT.m_cardNormalHeight / 2); int skip = 102; qreal whole_width = skip * 4; items.append(card_items); int n = items.length(); for (int i = 0; i < n; i++) { QPointF pos; if (n <= 10) { if (i < 5) { pos = pos1; pos.setX(pos.x() + i * skip); } else { pos = pos2; pos.setX(pos.x() + (i - 5) * skip); } } else { int half = (n + 1) / 2; qreal real_skip = whole_width / (half - 1); if (i < half) { pos = pos1; pos.setX(pos.x() + i * real_skip); } else { pos = pos2; pos.setX(pos.x() + (i - half) * real_skip); } } CardItem *item = items[i]; item->setPos(pos); item->setHomePos(pos); item->setOpacity(1.0); item->setHomeOpacity(1.0); item->setFlag(QGraphicsItem::ItemIsFocusable); if (disabled_ids.contains(item->getCard()->getEffectiveId())) item->setEnabled(false); item->show(); } }
void Move::pivot(vector<vector<double>>* zn, vector<vector<double>> z) { vector<vector<double>> buff = *zn; double ver = 1; if (rand01(rng) < 0.5) ver = -1; double beta = rand01(rng) * PI * ver; //max angle pi double teta = acos(rand01(rng)); ver = 1; if (rand01(rng) < 0.5) ver = -1; double fi = rand01(rng) * PI * ver; //max angle pi int nm = floor(rand01(rng) * (walkSize - 1)); int maxI = walkSize - nm; vector<vector<double>> pos(walkSize, vector<double>(3, 0)); vector<vector<double>> pos1(walkSize, vector<double>(3, 0)); for (int i = 0; i < maxI; ++i) for (int j = 0; j < 3; ++j) pos[i][j] = z[nm + i][j] - z[nm][j]; double rot[3][3]; dir(cos(teta), sin(teta), cos(fi), sin(fi), cos(beta), sin(beta), rot); for (int i = 0; i < maxI; ++i) { for (int j = 0; j < 3; ++j) { double sum = 0; for (int k = 0; k < 3; ++k) { sum += rot[j][k] * pos[i][k]; } pos1[i][j] = sum; } } inve(cos(teta), sin(teta), cos(fi), sin(fi), rot); for (int i = 0; i < maxI; ++i) { for (int j = 0; j < 3; ++j) { double sum = 0; for (int k = 0; k < 3; ++k) { sum += rot[j][k] * pos1[i][k]; } pos[i][j] = sum; } } for (int i = 0; i < maxI; ++i) for (int j = 0; j < 3; ++j) buff[nm + i][j] = pos[i][j] + z[nm][j]; if (nm != 0) for (int i = 0; i < nm; ++i) for (int j = 0; j < 3; ++j) buff[i][j] = z[i][j]; *zn = buff; }
void BotController::setGoal(float x, float y){ x; y; if (x > 40 && x < 1000 && y>40 && y < 760){ Vect pos1(x, y, 0, 1); goal = new Vect(x, y, 0, 1); newGoal = true; DebugMsg::out("setGoal :%f %f\n",x,y ); } }
boolean thisCase(void) { boolean Result; /* p2c: preamble.pas: Note: Eliminated unused assignment statement [338] */ if (!startsWithIgnoreCase(P[0], "case:")) return true; Result = (choice != ' ' && pos1(choice, P[0]) > 0); strcpy(P[0], "%"); return Result; }
Local void maybeGroup(struct LOC_scanMusic *LINK) { if (LINK->note[0] != grace_group) return; if (strlen(LINK->note) == 1) LINK->ngrace = 1; else LINK->ngrace = pos1(LINK->note[1], digits); /* bug if ngrace>9 */ if (LINK->ngrace > 0) LINK->ngrace--; }
/*determines type and sets the shape from the json * delete shape after use*/ void LevelObject::createFixture(Json::Value& jsonShape) { b2FixtureDef fixtureDef; int shapeType=jsonShape["type"].asInt(); /*note: the addFixture is in each case because of the shape scope*/ switch(shapeType){ case BOX:{ b2PolygonShape box; b2Vec2 pos(jsonShape["X"].asFloat(),jsonShape["Y"].asFloat()); box.SetAsBox(jsonShape["width"].asFloat(), jsonShape["height"].asFloat(), pos,0); fixtureDef.shape =&box; this->addFixture(fixtureDef); break; } case CIRCLE:{ b2CircleShape circle; circle.m_p.Set(jsonShape["X"].asFloat(),jsonShape["Y"].asFloat()); circle.m_radius = jsonShape["radius"].asFloat(); fixtureDef.shape =&circle; this->addFixture(fixtureDef); break; } case TRIANGLE:{ b2PolygonShape triangle; b2Vec2 vertices[3]; vertices[0].Set(jsonShape["X1"].asFloat(),jsonShape["Y1"].asFloat()); vertices[1].Set(jsonShape["X2"].asFloat(),jsonShape["Y2"].asFloat()); vertices[2].Set(jsonShape["X3"].asFloat(),jsonShape["Y3"].asFloat()); triangle.Set(vertices,3); fixtureDef.shape =▵ this->addFixture(fixtureDef); break; } case EDGE:{ b2EdgeShape edge; b2Vec2 pos1(jsonShape["X1"].asFloat(),jsonShape["Y1"].asFloat()); b2Vec2 pos2(jsonShape["X2"].asFloat(),jsonShape["Y2"].asFloat()); edge.Set(pos1,pos2); fixtureDef.shape =&edge; this->addFixture(fixtureDef); break; } default:{ b2PolygonShape box; box.SetAsBox(0.5,0.5); fixtureDef.shape =&box; this->addFixture(fixtureDef); break; } } }
bool CSuDokuSolver::checkForNakedPairs_SingleSquare( short iSquare ) { if ( PRINT_DEBUG) std::cout << "checkForHiddenDoubles_SingleSquare " << iSquare << std::endl; vector2d posOrigo; getPositionOfSquare( iSquare, posOrigo); short iSquareIndex2 = 0; bool bFound = false; for ( short iSquareIndex = 0; iSquareIndex < 9; ++iSquareIndex ) { iSquareIndex2 = iSquareIndex + 1; for ( ; iSquareIndex2 < 9; ++iSquareIndex2 ) { vector2d pos1( posOrigo.x + ( iSquareIndex % 3 ), posOrigo.y + ( iSquareIndex / 3 )); vector2d pos2( posOrigo.x + ( iSquareIndex2 % 3 ), posOrigo.y + ( iSquareIndex2 / 3 )); SuDokuCell::CSuDokuCell cell1 = m_oPossibleNumbers[pos1.x][pos1.y]; SuDokuCell::CSuDokuCell cell2 = m_oPossibleNumbers[pos2.x][pos2.y]; // Checkinf for naked pair two cell with only the two same numbers.. if ( cell1.isNakedPair(cell2) ) { if ( PRINT_DEBUG ) { std::cout << "...HiddenPair!" << pos1 << " and " << pos2 << " : " << cell1.getHiddenDouble1() << " & " << cell1.getHiddenDouble2() << std::endl; } // Remove all other instance of the found numbers in this column // TODO : Make this into a function // ...removePosibilities_Column( const short shColum, const short shExcept1, const short shExcept2, const short iDigit1, const short iDigit2) // Where shExcept1 and shExcept1 are the columns that make up the matching pairs ( should not have iDigit1 and iDigit2 removed // TODO2 : Make a MatchingPair struct that holds the positions, and the matchin digits ( ? ) bFound = RemovePossibilities_Square( posOrigo, cell1.getHiddenDouble1(), cell1.getHiddenDouble2(), iSquareIndex, iSquareIndex2 ); } // End check for naked pair // Check for hidden pair } } return bFound; }
void MainApplication::spawn_enemy() { // if(enemyCounter < MAX_ENEMY) //{ Ogre::String number = Ogre::StringConverter::toString(enemyCounter + 1); enemies.push_back("HeadNode" + number); Ogre::Entity* ogreHead = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode" + number); Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition()); headNode -> setPosition(Ogre::Vector3(1000, rand() % 800 - 400, pos1.z)); headNode -> attachObject(ogreHead); headNode->yaw(Ogre::Degree(-90)); enemyCounter++; // } }
Vector3 Branch::curvePos() { Vector3 pos1(m_curve[m_curveTarget].x * m_curveScale.x, m_curve[m_curveTarget].y * m_curveScale.y, m_curve[m_curveTarget].z * m_curveScale.z); Vector3 pos2(m_curve2[m_curveTarget].x * m_curveScale.x, m_curve2[m_curveTarget].y * m_curveScale.y, m_curve2[m_curveTarget].z * m_curveScale.z); Vector3 pos(pos1.x + ((pos2.x - pos1.x) * m_offset), pos1.y + ((pos2.y - pos1.y) * m_offset), pos1.z + ((pos2.z - pos1.z) * m_offset)); return pos; }
void SimpleGraphicsView::setCurrentLabelPositionToTextField() { if (currentRectItem_) { SimpleWithRectangleLabel* rectItem = qgraphicsitem_cast<SimpleWithRectangleLabel*>(currentRectItem_); if (rectItem) { ImgRect r; vec2 pos(rectItem->scenePos().x(), rectItem->scenePos().y()); vec2 pos1(rectItem->pos().x(), rectItem->pos().y()); r.rect_ = QRectF(rectItem->mapRectToScene(rectItem->rect())); r.label_ = rectItem->getLabel(); vec2 topLeft(r.rect_.topLeft().x(), r.rect_.topLeft().y()); vec2 rectSize(r.rect_.size().width(), r.rect_.size().height()); vec2 centerPos = topLeft+(rectSize/2.0f); emit currentRectItemPositionChanged(centerPos); } } }
void Triangle::build() { //Dessin 2D //glm::vec3 pos0(-1.0f, -1.0f, 0.0f); glm::vec3 pos0(-1.f, -1.f, 0.0f); glm::vec3 norm0(0.f, 0.f, 1.0f); glm::vec2 uv0(0.f, 0.f); //glm::vec3 pos1(1.0f, -1.0f, 0.0f); glm::vec3 pos1(3.f, -1.f, 0.0f); glm::vec3 norm1(0.f, 0.f, 1.0f); glm::vec2 uv1(2.f, 0.f); //glm::vec3 pos2(0.f, 0.5f, 0.0f); glm::vec3 pos2(-1.f, 3.0f, 0.0f); glm::vec3 norm2(0.f, 0.f, 1.0f); glm::vec2 uv2(0.f, 2.f); /* Pour un triangle faisant tout l'écran -1.0 -1.0 0.000000 1.0 -1.0 0.000000 0.0 0.5 0.000000 */ _vertices[0].position = pos0; _vertices[0].normal = norm0; _vertices[0].uv = uv0; _vertices[1].position = pos1; _vertices[1].normal = norm1; _vertices[1].uv = uv1; _vertices[2].position = pos2; _vertices[2].normal = norm2; _vertices[2].uv = uv2; _indices[0] = 0; _indices[1] = 1; _indices[2] = 2; }
TEST(ALPose2DTest, getAngle) { const float eps = 1e-4f; AL::Math::Pose2D pos1(1.5f, 0.0f, 0.0f); EXPECT_NEAR(pos1.getAngle(), 0.0f, eps); AL::Math::Pose2D pos2(1.5f, 0.0f, 2.0f); EXPECT_NEAR(pos2.getAngle(), 0.0f, eps); AL::Math::Pose2D pos3(1.0f, -1.0f, 2.0f); EXPECT_NEAR(pos3.getAngle(), -AL::Math::PI_4, eps); AL::Math::Pose2D pos4(0.0f, 1.0f, 1.0f); EXPECT_NEAR(pos4.getAngle(), AL::Math::PI_2, eps); AL::Math::Pose2D pos5(-2.0f, 1.0f, 2.0f); EXPECT_NEAR(pos5.getAngle(), 2.67792f, eps); }
// return true if there is at least one pair of tiles // that can be swapped so that a tripel tile can be // eliminated const bool GameField::isPlayable(void) const { bool playable = false; // we go through each column and row and swap single elements for ( unsigned int i = 0; i < FIELD_WIDTH-1; i++ ) { for ( unsigned int j = 0; j < FIELD_HEIGHT-1; j++ ) { // set positions for swapping FieldPos pos1(i,j); FieldPos pos2(i,j+1); if (isPlayable(pos1,pos2)) { playable = true; // leave for-loop break; } // set positions for swapping pos1.set(i,j); pos2.set(i+1,j); if ( isPlayable(pos1,pos2) ) { playable = true; // leave for-loop break; } } if ( playable ) { // leave for-loop break; } } return playable; }