Example #1
0
void genePredWriteToGtf(struct genePred *gp, char *source, 
	struct hash *dupeHash, FILE *f)
/* Write out genePredName to GTF file. */
{
int i;
char *name = findUniqueName(dupeHash, gp->name);
char *geneName = gp->name2;
char *chrom = gp->chrom;
char strand = gp->strand[0];
int *frames = (gp->optFields & genePredExonFramesFld) ? gp->exonFrames : calcFrames(gp);
struct codonCoords firstCodon = findFirstCodon(gp, frames);
struct codonCoords lastCodon = findLastCodon(gp, frames);

// figure out bounds of CDS and UTR regions, moving stop codon to outside of
// CDS.
int firstUtrEnd = gp->cdsStart, lastUtrStart = gp->cdsEnd;
int cdsStart = gp->cdsStart, cdsEnd = gp->cdsEnd;
if ((strand == '+') && codonComplete(&lastCodon))
    cdsEnd = movePos(gp, lastUtrStart, -3);
if ((strand == '-') && codonComplete(&firstCodon))
    cdsStart = movePos(gp, cdsStart, 3);

if (addComments)
    fprintf(f, "###\n# %s %s:%d-%d (%s) CDS: %d-%d\n#\n",
            gp->name, gp->chrom, gp->txStart, gp->txEnd,
            gp->strand, gp->cdsStart, gp->cdsEnd);

for (i=0; i<gp->exonCount; ++i)
    {
    writeGtfLine(f, source, name, geneName, chrom, strand, "exon", 
             gp->exonStarts[i], gp->exonEnds[i], i, -1);
    if (cdsStart < cdsEnd)
        writeFeatures(gp, i, source, name, chrom, strand, geneName, 
                      firstUtrEnd, cdsStart, cdsEnd, lastUtrStart,
                      frames[i], f);
    }
if (gp->strand[0] == '+')
    {
    if (codonComplete(&firstCodon))
        writeCodon(f, source, name, geneName, chrom, strand, "start_codon", 
                   &firstCodon);
    if (codonComplete(&lastCodon))
        writeCodon(f, source, name, geneName, chrom, strand, "stop_codon",
                   &lastCodon);
    }
else
    {
    if (codonComplete(&lastCodon))
        writeCodon(f, source, name, geneName, chrom, strand, "start_codon",
                   &lastCodon);
    if (codonComplete(&firstCodon))
        writeCodon(f, source, name, geneName, chrom, strand, "stop_codon",
                   &firstCodon);
    }
if (!(gp->optFields & genePredExonFramesFld))
    freeMem(frames);
}
Example #2
0
static void one_step(guint richting)
{
  update_tux(richting);

  switch (richting)
    {
    case WEST: movePos(position[ind][0],position[ind][1],position[ind][0]-1,position[ind][1],richting);
      return;
    case EAST: movePos(position[ind][0],position[ind][1],position[ind][0]+1,position[ind][1],richting);
      return;
    case NORTH: movePos(position[ind][0],position[ind][1],position[ind][0],position[ind][1]-1,richting);
      return;
    case SOUTH: movePos(position[ind][0],position[ind][1],position[ind][0],position[ind][1]+1,richting);
      return;
    }
}
//-------------------------- ctor ---------------------------------------------
//-----------------------------------------------------------------------------
TargetSplashSkill::TargetSplashSkill(
	
	AbstCharacter* const shooter,
	AbstCharacter* const target,
	float splash_radius,
	int damage,
	int radius,
	int max_speed,
	double survive_time,
	const std::string& name,
	int team)
	:
	AbstTargetSkill(
		shooter->getWorld(),
		target,
		shooter->getId(),
		shooter->getPos(),
		shooter->getHeading(),
		damage,
		radius,
		max_speed,
		1,
		10,
		name,
		SKILL,
		survive_time),
	_activated(false)
{
	CCASSERT(target, "target == nullptr");
	setTeam(team);
	movePos(_heading * _bounding_radius);
	_activate_strategy.reset(new ActivateCollisionToTarget(this));
	_impact_strategy.reset(new ImpactSplash(this, shooter, splash_radius));
}
Example #4
0
void setCenter()
{
#ifdef __CLASSFICATION_MOTOR__
    torqueControl( CLASSFICATION_MOTOR_ID, TORQUE_ON );
    movePos( CLASSFICATION_MOTOR_ID, 512, 60 );
#endif
}
Example #5
0
void classify( int grade )
{
#ifdef __CLASSFICATION_MOTOR__
    if( grade >= 0 && grade < GRADE_NUM )
        movePos( CLASSFICATION_MOTOR_ID, POSITION_TABLE[ grade ], 30 );
#endif
}
/**
 * Move HerkuleX Servo by angle(degree value - NOT Radian) (-159.8~159.8)
 * (Degree = Position Value * 0.325)
 *
 * void moveAngle(uint8_t id, float angle, uint8_t playtime, uint8_t led)
 *
 * id - HerkuleX Servo ID
 * angle - (-159.8 ~ 159.8) See. Manual p31~32
 * playtime : Time to target position. (playtime * 11.2)ms. 1 - 11.2ms 2 - 22.4ms ...
 * led - Red - 0x01, Green - 0x04, Blue - 0x08
 *
 */
void CHerkuleX::moveAngle(uint8_t id, float angle, uint8_t playtime, uint8_t led) {
	if (angle > 166.7 || angle < -166.7) return;	// Full range
	//if (angle > 159.8 || angle < -159.8) return; 		// Recommended range
	if (playtime > 255) return;

	uint16_t pos = (uint16_t)(angle/0.325f) + 512;
	movePos(id, pos, playtime, led);
}
void TargetSplashSkill::updateMovement(double time_elapsed)
{

	_velocity = getMaxSpeed() * (_target->getPos() - _pos).getNormalized();

	//make sure vehicle does not exceed maximum velocity
	if (_velocity.getLength() > _max_speed)
	{
		_velocity.normalize();
		_velocity *= _max_speed;
	}

	movePos(_velocity);
}
Example #8
0
void Player::fixedUpdate(float deltaTime) {
    transform = glm::translate(mat4f(1.0), pos);
    this->propragateTransforms();

    lastPos = pos;

    //move and update camera position
    if(!Debugger::isShown()) movePos(deltaTime); //this handles collisions

    //Limit movement
    disp.x = 0; // Player only accelerates vertically, so disp.x doesn't carry
    disp.y = std::fmax(-70, disp.y);
    disp.z = 0; // Player only accelerates vertically, so disp.z doesn't carry

    //feedback to be used by the scene
    onFloor = hitbox->collidesWithWorld(vec3f(0,-0.1,0));
    isJumping = (disp.y > 0);
}
/*
 * \brief Run Calibration
 *
 *
 */
bool MapDemonCtrl::runCalibration()
{
  std::ostringstream errorMsg;
  std::vector<std::string> JointNames = params_->getJointNames();
  std::vector<double> MaxVel = params_->getMaxVel();

  /// Shut robot output in case it was already enabled...
  usleep(200000);
  if( !sd_->FlushInBuffer() )
    return false;	/// ...and flush serial port input buffer
  usleep(200000);

  /// Run encoder calibration
  sd_->PutString("L\n");

  size_t found = std::string::npos;
  char retry = 0;	//

  /// get messages till 'L' is received (this is necessary because if the message output of the robot was enabled, between the flush buffer and this we still could have received a few characters from that, before the 'L'.
  while( found == std::string::npos )
  {
    std::string str;
    sd_->GetString(str);	// read another message
    found = str.find_first_of("L", 0);	// find L
    retry++;
    std::cout << "calib cb: " << str << std::endl;
    if(retry == 4)	// experimental value, normally one or two messages are received btw flushinbuffer and getstring.
      return false;	/// if tryout
  }

  //char *cstr = new char (str.size()+1);
  //strcpy(cstr, str.c_str());

  //if(strchr(cstr, 'L') == NULL)
  //	return false;

  /// Reposition to Home in case of existant Offsets
  std::vector<double> tmppos( 2, 0.0f );
  movePos(tmppos);

  return true;
}
Example #10
0
void Skeleton::update(float deltaTime) {
	movePos(deltaTime);
	updateMatrix();

	if(parentScene->getWorld()->getCube(pos.x,pos.y,pos.z).ID == 0)
		ambientLight = float(parentScene->getWorld()->getCube(pos.x,pos.y,pos.z).light)/MAXLIGHT;

	cooldown -= deltaTime;
	if (cooldown <= 0) {
		cooldown = 1;
		Arrow* na = new Arrow(parentScene,(pos+shootPosOffset));
		na->vel = targetPlayer->camPos-(pos+shootPosOffset);
		na->vel = glm::normalize(na->vel);
		na->vel *= 70.0f;
		parentScene->addObject(na);
	}

	vel.x = 0; // Mobs only accelerate vertically, so speed.x doesn't carry
	vel.y = std::fmax(-70,vel.y);
	vel.z = 0; // Mobs only accelerate vertically, so speed.z doesn't carry
}
Example #11
0
float3 CSelectedUnitsAI::MoveToPos(int unit, float3 nextCornerPos, float3 dir, Command* command, std::vector<std::pair<int,Command> >* frontcmds, bool* newline)
{
	//int lineNum=posNum/numColumns;
	//int colNum=posNum-lineNum*numColumns;
	//float side=(0.25f+colNum*0.5f)*columnDist*(colNum&1 ? -1:1);
	*newline = false;
	if ((nextCornerPos.x - addSpace) > frontLength) {
		nextCornerPos.x = 0; nextCornerPos.z -= avgLength * 2 * 8;
		*newline = true;
	}
	if (!frontcmds) {
		return nextCornerPos;
	}
	int unitSize = 16;
	const CUnit* u = uh->units[unit];
	if (u) {
		const UnitDef* ud = u->unitDef;
		unitSize = (int)((ud->xsize + ud->zsize) / 2);
	}
	float3 retPos( nextCornerPos.x + unitSize * 8 * 2 + addSpace, 0, nextCornerPos.z);
	float3 movePos(nextCornerPos.x + unitSize * 8     + addSpace, 0, nextCornerPos.z); // posit in coordinates of "front"
	if (nextCornerPos.x == 0) {
		movePos.x = unitSize * 8;
		retPos.x -= addSpace;
	}
	float3 pos;
	pos.x = rightPos.x + (movePos.x * (dir.x / dir.y)) - (movePos.z * (dir.z/dir.y));
	pos.z = rightPos.z + (movePos.x * (dir.z / dir.y)) + (movePos.z * (dir.x/dir.y));
	pos.y = ground->GetHeightAboveWater(pos.x, pos.z);

	Command c(command->GetID(), command->options);
	c.params.push_back(pos.x);
	c.params.push_back(pos.y);
	c.params.push_back(pos.z);

	frontcmds->push_back(std::pair<int, Command>(unit, c));

	return retPos;
}
Example #12
0
float3 CSelectedUnitsAI::MoveToPos(int unit, float3 nextCornerPos, float3 dir, Command* command)
{
    //int lineNum=posNum/numColumns;
    //int colNum=posNum-lineNum*numColumns;
    //float side=(0.25f+colNum*0.5f)*columnDist*(colNum&1 ? -1:1);

    if(nextCornerPos.x-addSpace>frontLength) {
        nextCornerPos.x=0;
        nextCornerPos.z-=avgLength*2*8;
    }
    int unitSize=16;
    CUnit* u = uh->units[unit];
    if (u) {
        const UnitDef* ud = u->unitDef;
        unitSize = (int)((ud->xsize + ud->zsize)/2);
    }
    float3 retPos(nextCornerPos.x+unitSize*8*2+addSpace, 0, nextCornerPos.z);
    float3 movePos(nextCornerPos.x+unitSize*8+addSpace, 0, nextCornerPos.z); //posit in coordinates of "front"
    if (nextCornerPos.x==0) {
        movePos.x=unitSize*8;
        retPos.x -= addSpace ;
    }
    float3 pos;
    pos.x = rightPos.x + (movePos.x * (dir.x / dir.y)) - (movePos.z * (dir.z/dir.y));
    pos.z = rightPos.z + (movePos.x * (dir.z / dir.y)) + (movePos.z * (dir.x/dir.y));
    pos.y = ground->GetHeight(pos.x, pos.z);

    Command c;
    c.id = command->id;
    c.params.push_back(pos.x);
    c.params.push_back(pos.y);
    c.params.push_back(pos.z);
    c.options = command->options;

    uh->units[unit]->commandAI->GiveCommand(c, false);
    return retPos;
}
Example #13
0
 void move(Index index)
   {
     const Index pos(this->positionVector[index]);
     movePos(pos);
   } 
Example #14
0
void Hole::motionPrint(Output* graphic){
	static int cnt = 0;
	static int num_cnt = 0;

	switch (cnt) {	//기본 모양 한칸씩 내리는거 없애기...그것때문에 제어못하는 경우가 좀 생기는거 같아..
	case 0: 
		shape = 0;
		y = 0;
		break;
	case 1:
		y = 1;
		break;
	case 2:
		shape = 1;//좌표 4는 하지말기
		y = 2;
		break;
	case 3:
		shape = 2;
		y = 3;
		break;
	case 4:
		shape = 2;
		y = 4;
		break;
	case 5:
		shape = 3;
		y = 6;
		break;
	case 6:
		shape = 3;
		y = 8;
		break;
	case 7:
		shape = 4;
		y = 10;
		break;
	case 8:	
		shape = 4;
		y = 13;
		break;
	case 9:
		shape = 4;
		y = 16;
		break;
	case 10:
		shape = 4;
		y = 18;
		cnt = 0;
		break;
	//case 11:
	//	y = 19;
		//y = 3;	//안보이게 
	}
	if (num_cnt % 2)
		cnt++;
	num_cnt++;

	movePos();

	memcpy(presentForm, form[shape%5], sizeof(int) * 9 * 11);//결정된 동작을 현재 형태에 복사
	graphic->fixOnBoard(this);	//출력 보드에 현재 객체 배치. 좌표와 형태 모두 필요.
}