Ejemplo n.º 1
0
float Player::computeZenith (AudioObj* obj) const {
    if (this->computeRadius(obj) == 0) {
		return 0;
	} else {
		return asin((obj->getLocation().getY() - location.getY()) / computeRadius(obj)) * R2D;
    }
}
Ejemplo n.º 2
0
// Start a new race.
void Driver::newRace(tCarElt* car, tSituation *s)
{
	float deltaTime = (float) RCM_MAX_DT_ROBOTS;
	MAX_UNSTUCK_COUNT = int(UNSTUCK_TIME_LIMIT/deltaTime);
	OVERTAKE_OFFSET_INC = OVERTAKE_OFFSET_SPEED*deltaTime;
	stuck = 0;
	alone = 1;
	clutchtime = 0.0f;
	oldlookahead = 0.0f;
	this->car = car;
	CARMASS = GfParmGetNum(car->_carHandle, SECT_CAR, PRM_MASS, NULL, 1000.0f);
	myoffset = 0.0f;
	initCa();
	initCw();
	initTireMu();
	initTCLfilter();

	// Create just one instance of cardata shared by all drivers.
	if (cardata == NULL) {
		cardata = new Cardata(s);
	}
	mycardata = cardata->findCar(car);
	currentsimtime = s->currentTime;

	// initialize the list of opponents.
	opponents = new Opponents(s, this, cardata);
	opponent = opponents->getOpponentPtr();

	// Set team mate.
	const char *teammate = GfParmGetStr(car->_carHandle, BT_SECT_PRIV, BT_ATT_TEAMMATE, NULL);
	if (teammate != NULL) {
		opponents->setTeamMate(teammate);
	}

	// Initialize radius of segments.
	radius = new float[track->nseg];
	computeRadius(radius);

	learn = new SegLearn(track, s, INDEX);

	// create the pit object.
	pit = new Pit(s, this);
}
Ejemplo n.º 3
0
/******************************************************************//**
 * Initializing protein class
 ******************************************************************/
CProtein::CProtein(const char *fname) {
	vector<AA> aas;
	string ss = fname;

	if (ss.find("pdb") != std::string::npos) {
		CPDB::loadFromPDB(fname, aas);
	} else if (ss.find("pqr") != std::string::npos) {
		CPDB::loadFromPQR(fname, aas);
	}

	// Add each atom in each amino acid of protein to matrix of atoms
	for (int i = 0; i < aas.size(); i++)
		for (int j = 0; j < aas[i].getNumAtoms(); j++)
			m_atoms.push_back(aas[i][j]);

	// Add charge on atom in each amino acid to vector of charges
	for (int i = 0; i < m_atoms.size(); i++) {
		if (m_atoms[i].getCharge() != 0.0)
			m_chargedAtoms.push_back(&(m_atoms[i]));
	}

	m_center = computeCenter(); // compute center of geometry if the atom
	// reposition each atom WRT to the center of mass of protein
	for (int i = 0; i < m_atoms.size(); i++)
		m_atoms[i].setPos(m_atoms[i].getPos() - m_center);

	computeRadius();

	m_sumCharge = 0.0; // Total charge of protein
	for (int i = 0; i < getNumCharges(); i++) m_sumCharge += getCharge(i);

	REAL s = 0.0; // Total charge of protein to print as output
	for (int i = 0; i < getNumCharges(); i++) s += (getCharge(i));
	cout << "sum = " << s << " rad = " << m_rad << endl;

	// Creating a multipole expansion class for the protein
	m_mpe = new CMPE(*this);

	m_exps.push_back(m_mpe); // Pushing the MPE to an array
	// Adding the protein center to an array of centers
	m_cens.push_back(&m_center);
	m_mols.push_back(this); // Adding the protein to an array of proteins
}
Ejemplo n.º 4
0
scene::Vector3 scene::LLAToECEFTransform::transform(const LatLonAlt& lla)
{
    Vector3 ecef;
    
    LatLonAlt mylla = lla;
    
    if (std::abs(mylla.getLatRadians()) > M_PI/2
	|| std::abs(mylla.getLonRadians()) > M_PI)
    {
	//invalid lla coordinate
	std::ostringstream str;
	str <<  "Invalid lla coordinate: ";
	str << "lat=";
	str << lla.getLatRadians();
	str << ", lon=";
	str << lla.getLonRadians();
	str << ", alt=";
	str << lla.getAlt();
	
	throw except::InvalidFormatException(str.str());
    }
    
    //do conversion here; store result in ecef struct
    
    double r = computeRadius(mylla);
    double flatLat = computeLatitude(mylla.getLatRadians());
    
    double coslat = cos(mylla.getLatRadians());
    double coslon = cos(mylla.getLonRadians());
    double cosflatlat = cos(flatLat);
    double sinlat = sin(mylla.getLatRadians());
    double sinlon = sin(mylla.getLonRadians());
    double sinflatlat = sin(flatLat);
    
    
    ecef[0] = (r * cosflatlat * coslon) + (mylla.getAlt() * coslat * coslon);
    ecef[1] = (r * cosflatlat * sinlon) + (mylla.getAlt() * coslat * sinlon);
    ecef[2] = (r * sinflatlat) + (mylla.getAlt() * sinlat);
    
    return ecef;
}