uint16_t calculateHeight(struct symbol* node) { /* we've reached the end, return 0 */ if (node == NULL) { return 0; } uint16_t left_subtree_height = calculateHeight(node->left); uint16_t right_subtree_height = calculateHeight(node->right); if (left_subtree_height < right_subtree_height) return right_subtree_height + 1; else return left_subtree_height + 1; }
AMAction3* BioXASMirrorRollControl::createMoveAction(double setpoint) { AMAction3 *result = 0; if (isConnected()) { AMListAction3 *move = new AMListAction3(new AMListActionInfo3(name()+" move", name()+" move"), AMListAction3::Parallel); double pitch = calculatePitch(upstreamInboard_->xPosition(), upstreamInboard_->yPosition(), upstreamInboard_->zPositionSetpoint(), upstreamOutboard_->xPosition(), upstreamOutboard_->yPosition(), upstreamOutboard_->zPositionSetpoint(), downstream_->xPosition(), downstream_->yPosition(), downstream_->zPositionSetpoint()); double height = calculateHeight(upstreamInboard_->xPosition(), upstreamInboard_->yPosition(), upstreamInboard_->zPositionSetpoint(), upstreamOutboard_->xPosition(), upstreamOutboard_->yPosition(), upstreamOutboard_->zPositionSetpoint(), downstream_->xPosition(), downstream_->yPosition(), downstream_->zPositionSetpoint()); double upstreamInboardDestination = calculateUpstreamInboardPosition(upstreamInboard_->xPosition(), upstreamInboard_->yPosition(), pitch, setpoint, height); move->addSubAction(AMActionSupport::buildControlMoveAction(upstreamInboard_, upstreamInboardDestination)); double upstreamOutboardDestination = calculateUpstreamOutboardPosition(upstreamOutboard_->xPosition(), upstreamOutboard_->yPosition(), pitch, setpoint, height); move->addSubAction(AMActionSupport::buildControlMoveAction(upstreamOutboard_, upstreamOutboardDestination)); double downstreamDestination = calculateDownstreamPosition(downstream_->xPosition(), downstream_->yPosition(), pitch, setpoint, height); move->addSubAction(AMActionSupport::buildControlMoveAction(downstream_, downstreamDestination)); result = move; } return result; }
SWSolver::SWSolver(int xRes, int yRes, float xSize, float ySize, float dt) { // initialize defaults a_ext[0] = 0; a_ext[1] = 0; v_ext[0] = 0; v_ext[1] = 0; g = 9.81f; ground.resize(xRes*yRes); // initializes all values to zero eta.resize(xRes*yRes); eta.assign(xRes*yRes, 1); // put some default values height.resize(xRes*yRes); vel_x.resize(xRes*yRes); // vel_x.assign(xRes*yRes, 5.0f); vel_y.resize(xRes*yRes); // vel_x.assign(xRes*yRes, 5.0f); // rest this->res[0] = xRes; this->res[1] = yRes; this->xSize = xSize; this->ySize = ySize; this->dt = dt; this->dx[0] = xSize/xRes; this->dx[1] = ySize/yRes; calculateHeight(); }
GLboolean MountainConstructor::calculateActiveVoxel(GLfloat x, GLfloat z, GLfloat y) { if ( y == 0 ) { return GL_TRUE; } if (calculateHeight(x,z) > y) { return GL_TRUE; } else { return GL_FALSE; } }
void calculateArea(const int numRects, const int myNumRects, const double width, const int myDispl, double *area) { int i = 0; double height = 0.0; for (i = myDispl; i < (myDispl + myNumRects); i++) { calculateHeight(i, width, &height); (*area) += (width * height); } }
void calculateArea(const int numRects, const double width, double *area) { int i = 0; double height = 0.0; (*area) = 0.0; for (i = 0; i < numRects; i++) { calculateHeight(i, width, &height); (*area) += (width * height); } }
void Robot::shootBullet(){ SoundHelper::getInstance()->play("shoot.wav", 1, false); if(robotLife>0){ spinDirectionVector(); //check which component is highest int highestIndex = 0; for(int i = 3; i <= 5; i++){ if(isPartOn[i]){ highestIndex = i; } } GLfloat yPosition = calculateHeight(highestIndex); GLfloat bulletSpawnOffset[2]; GLfloat bulletSpawnOffset2[2]; //create bullet at spawn point switch(highestIndex){ case 5: //rotate offset bulletSpawnOffset[0] = -.7f*cos((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset[1] = .7f*sin((spinDegrees)*DegreesToRadians) +0.5f; //Rotate bm->addBullet(xPos+bulletSpawnOffset[0],yPosition-0.3f,zPos+bulletSpawnOffset[1],directionVector[0],directionVector[1],directionVector[2], spinDegrees); break; case 4: //rotate offset bulletSpawnOffset[0] = -0.7f*cos((spinDegrees)*DegreesToRadians) - 0.35f*sin((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset[1] = 0.7f*sin((spinDegrees)*DegreesToRadians) - 0.35f*cos((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset2[0] = -0.7f*cos((spinDegrees)*DegreesToRadians) + 0.35f*sin((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset2[1] = 0.7f*sin((spinDegrees)*DegreesToRadians) + 0.35f*cos((spinDegrees)*DegreesToRadians) + 0.5f; //spawn point needs to accomodate rotation bm->addBullet(xPos+bulletSpawnOffset[0],yPosition-0.2f,zPos+bulletSpawnOffset[1],directionVector[0],directionVector[1],directionVector[2], spinDegrees); bm->addBullet(xPos+bulletSpawnOffset2[0],yPosition-0.2f,zPos+bulletSpawnOffset2[1],directionVector[0],directionVector[1],directionVector[2], spinDegrees); break; case 3: //offset facing south bulletSpawnOffset[0] = -0.85f*cos((spinDegrees)*DegreesToRadians) - 0.15f*sin((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset[1] = 0.85f*sin((spinDegrees)*DegreesToRadians) - 0.15f*cos((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset2[0] = -0.85f*cos((spinDegrees)*DegreesToRadians) + 0.15f*sin((spinDegrees)*DegreesToRadians) + 0.5f; bulletSpawnOffset2[1] = 0.85f*sin((spinDegrees)*DegreesToRadians) + 0.15f*cos((spinDegrees)*DegreesToRadians) + 0.5f; //spawn point needs to accomodate rotation bm->addBullet(xPos+bulletSpawnOffset[0],yPosition-.2f,zPos+bulletSpawnOffset[1],directionVector[0],directionVector[1],directionVector[2], spinDegrees); bm->addBullet(xPos+bulletSpawnOffset2[0],yPosition-.2f,zPos+bulletSpawnOffset2[1],directionVector[0],directionVector[1],directionVector[2], spinDegrees); default: break; } } }
void SWSolver::setGround(std::vector<float> ground){ this->ground = ground; calculateHeight(); }
void SWSolver::setEta(std::vector<float> eta){ this->eta = eta; calculateHeight(); }
void FavoritesView::resetSize() { calculateHeight(); }
void DayBreak::updateWidth(HWND window, int width) { this->width = width; calculateHeight(); }
// Force a reset of the size. Useful when hiding tags so that the display looks // correct. void NTagView::resetSize() { calculateHeight(); }
void NAttributeTree::resetSize() { calculateHeight(); }
void ChatControlMessageFrame::updateWidth(HWND window, int width) { this->width = width; message->updateWidth(window, width); calculateHeight(); }
void Robot::refreshRobot(){ clearChildren(); //setup if(isPartOn[0]){ model = bipodM; } else if (isPartOn[1]){ model = tracksM; } else if (isPartOn[2]){ model = antiGravM; } Model* temp = NULL; Model* tempChild = NULL; bool childExists = false; bool grandChildExists = false; for(int i = 7; i > 2; i--){ if(isPartOn[i]){ if(childExists){ grandChildExists = true; } childExists = true; tempChild = temp; switch(i){ case 3: temp = cannonM; break; case 4: temp = missileM; break; case 5: temp = phaserM; break; case 6: temp = nuclearM; break; case 7: temp = electronicsM; break; default: break; } if(grandChildExists){ temp->setNextChild(tempChild); } } } if(childExists){ model->setNextChild(temp); } calculateHeight(); if(hasBox){ if(robotLife > 0){ box->resize(box->size.x,height,box->size.z); } else{ box->resize(box->size.x,0.01f,box->size.z); } } notifyCamera(); }
void NTrashTree::resetSize() { calculateHeight(); }
int Node::getHeight() { calculateHeight(); return height; }
QSize QgsColorSwatchGrid::sizeHint() const { return QSize( mWidth, calculateHeight() ); }
void NNotebookView::resetSize() { calculateHeight(); }