コード例 #1
0
void SideStrafeGeneral(const PlayerData& player, const MovementVars& vars, bool onground, double wishspeed,
	const StrafeButtons& strafeButtons, bool useGivenButtons, Button& usedButton, double vel_yaw, double theta, bool right, Vector2D& velocity, double& yaw)
{
	if (useGivenButtons) {
		if (!onground) {
			if (right)
				usedButton = strafeButtons.AirRight;
			else
				usedButton = strafeButtons.AirLeft;
		} else {
			if (right)
				usedButton = strafeButtons.GroundRight;
			else
				usedButton = strafeButtons.GroundLeft;
		}
	} else {
		usedButton = GetBestButtons(theta, right);
	}
	double phi = ButtonsPhi(usedButton);
	theta = right ? -theta : theta;

	if (!player.Velocity.AsVector2D().IsZero(0))
		vel_yaw = Atan2(player.Velocity.y, player.Velocity.x);

	yaw = NormalizeRad(vel_yaw - phi + theta);

	Vector2D avec(std::cos(yaw + phi), std::sin(yaw + phi));
	PlayerData pl = player;
	VectorFME(pl, vars, onground, wishspeed, avec);
	velocity = pl.Velocity.AsVector2D();
}
コード例 #2
0
ファイル: Saliency.cpp プロジェクト: assamite/sdrs_cimg
//===========================================================================
///	GetSaliencyMap
///
/// Outputs a saliency map with a value assigned per pixel. The values are
/// normalized in the interval [0,255] if normflag is set true (default value).
//===========================================================================
void Saliency::GetSaliencyMap(
	const vector<UINT>&				inputimg,
	const int&						width,
	const int&						height,
	vector<double>&					salmap,
	const bool&						normflag) 
{
	int sz = width*height;
	salmap.clear();
	salmap.resize(sz);

	vector<double> lvec(0), avec(0), bvec(0);
	RGB2LAB(inputimg, lvec, avec, bvec);
	//--------------------------
	// Obtain Lab average values
	//--------------------------
	double avgl(0), avga(0), avgb(0);
	{for( int i = 0; i < sz; i++ )
	{
		avgl += lvec[i];
		avga += avec[i];
		avgb += bvec[i];
	}}
	avgl /= sz;
	avga /= sz;
	avgb /= sz;

	vector<double> slvec(0), savec(0), sbvec(0);

	//----------------------------------------------------
	// The kernel can be [1 2 1] or [1 4 6 4 1] as needed.
	// The code below show usage of [1 2 1] kernel.
	//----------------------------------------------------
	vector<double> kernel(0);
	kernel.push_back(1.0);
	kernel.push_back(2.0);
	kernel.push_back(1.0);

	GaussianSmooth(lvec, width, height, kernel, slvec);
	GaussianSmooth(avec, width, height, kernel, savec);
	GaussianSmooth(bvec, width, height, kernel, sbvec);

	{for( int i = 0; i < sz; i++ )
	{
		salmap[i] = (slvec[i]-avgl)*(slvec[i]-avgl) +
					(savec[i]-avga)*(savec[i]-avga) +
					(sbvec[i]-avgb)*(sbvec[i]-avgb);
	}}

	if( true == normflag )
	{
		vector<double> normalized(0);
		Normalize(salmap, width, height, normalized);
		swap(salmap, normalized);
	}
}
コード例 #3
0
ファイル: gsortvec.cpp プロジェクト: dhaley/dcp
main()  {
  // Declare and define an instance,
  // using the comparison function 'compFun':
  RWGSortedVector(int) avec(compFun);

  int someData[6] = {3, 17, 4, 5, 32, -1};

  cout << "When these numbers are inserted as follows:"
       << endl << "\t";


  // Do some insertions:
  int i = 0;
  while(someData[i] > 0)
  {
     avec.insert(someData[i]);
     cout << someData[i++] << "\t";
  }
 

  cout << endl << endl << "Now the RWGSortedVector is ordered as follows: "
       << endl << "\t";

  for(i = 0; i < avec.entries(); i++)
     cout << avec(i) << "\t";


  cout << endl << endl
       << "The second element is: " << avec(1);   

  cout << endl 
       << "The index of the first odd element is: " << avec.index(1)
       << endl; 

  return 0;
}
コード例 #4
0
ファイル: pnivec4.cpp プロジェクト: prwhite/philibs
void
vec4::
xformVec ( const vec4& srcIn, 
		const quat& quatIn )
{
	quat inv ( quatIn );
	inv.invert ();
	
	ValueType divisor = srcIn[ 3 ];
	vec4 src ( srcIn );
	src /= divisor;			// get the vec out o.homogeneous coords

	quat avec ( src[ 0 ], src[ 1 ], src[ 2 ], TraitType::zeroVal );
	
	avec = inv * avec * quatIn;
	
	vec[ 0 ] = avec[ 0 ];
	vec[ 1 ] = avec[ 1 ];
	vec[ 2 ] = avec[ 2 ];
	vec[ 3 ] = TraitType::oneVal;
	
	*this *= divisor;
}