Пример #1
0
/**
 * Add an edge to this node in specified direction
 */
void
Node::addEdgeInDir( Edge *edge, GraphDir dir)
{
    graphassert( isNotNullP( edge));
    EdgeListItem *it = edge->getNodeIt( revDir( dir));
    it->attach( edges[ dir]);
    edges[ dir] = it;
}
Пример #2
0
static void revolve (float c[3], float mystate[12], float other[12])
{
//BEGIN::PROC::revolve
/*
 * Revolving function
 */
float v[4];
float q[4];
float a[4];
float a2[4];
float asse[3];
float d;
float b;
float b2;
int dir=sp;

if (PisRevolving (other)) {
	dir = revDir (other,c);
	if (!dir)
		dir=sp;
}

PgetAsteroidNormal(asse);

v[3]=0;

mathVecSubtract (v,c,mystate,3);

d=mathVecMagnitude(v, 3);
if(d >= 0.3f) {
	d=0.2355f/d; // (pi/2)*(0.3/distance)
}
else {
	d= 1.57f - 2.615f*d; // pi - (pi/2)*(distance/0.25)
}

// This creates the quaternion
// (yeah, a quaternion, that's cool right?)
b=d-1.57f;
b2=b*b*b;
q[3]=(-b + b2/6 - b2*b*b/120);
b2=d*d*d;
mathVecMul (q,asse,dir*(d - b2/6 + b2*d*d/120)); 

// v[] is rotated according to the quaternion
funz(a2,q,v);
mathVecMul(q,q,-1);
funz(a,a2,q);

//then it's normalized and converted in velocity
mathVecNormalize(a, 3);
mathVecMul(a,a,0.0232f);
ZRSetVelocityTarget(a);


q[3]=1;
mathVecMul(q,asse,-dir*0.043619f);

funz(a2,q,v);
mathVecMul(q,q,-1);
funz(a,a2,q);

ZRSetAttitudeTarget(a);

//END::PROC::revolve
}