Ejemplo n.º 1
0
/************************************************************************************************
* Ball initialization                                                                           *
************************************************************************************************/
void cBall::Init(vector3f pos, vector3f dir, float vel, float r)
{
    this->Pos = vInit(pos);
    this->Dir = vInit(dir);
    this->Vel = vel;
    this->R   = r;
}
Ejemplo n.º 2
0
/************************************************************************************************
* Bouncher initialization                                                                       *
************************************************************************************************/
void cBouncher::Init(vector3f pos, vector3f dir, float vel, float r, float size, unsigned int texture)
{
    this->Pos     = vInit(pos);
    this->Dir     = vInit(dir);
    this->Vel     = vel;
    this->R       = r;
    this->Size    = size;
    this->Texture = texture;
}
Ejemplo n.º 3
0
/* main ===================================================================== */
int
main (void) {
  vInit ();

  for (;;) {

    vMenuLoop ();
  }
}
Ejemplo n.º 4
0
std::shared_ptr<ActorComponent> BaseActorFactory::BaseActorFactoryImpl::___createComponent(const tinyxml2::XMLElement * componentElement) const
{
	auto componentType = componentElement->Value();
	auto component = m_ComponentFactory.createShared(componentType);

	assert(component && "BaseActorFactoryImpl::___createComponent() can't find or create the ActorComponent as the xml indicated, possibly because the component is not registered to the factory.");

	if (!component->vInit(componentElement)) {
		cocos2d::log("BaseActorFactoryImpl::___createComponent failed to initialize a(n) %s", componentType);
		return nullptr;
	}

	return component;
}
/****************************************************************************
 *
 * NAME: AppColdStart
 *
 * DESCRIPTION:
 * Entry point for application from boot loader. Initialises system and runs
 * main loop.
 *
 * RETURNS:
 * Never returns.
 *
 ****************************************************************************/
PUBLIC void AppColdStart(void)
{
	/* Debug hooks: include these regardless of whether debugging or not */
	HAL_GDB_INIT();
    HAL_BREAKPOINT();

	/* Set network information */
	JZS_sConfig.u32Channel = WSN_CHANNEL;
	JZS_sConfig.u16PanId   = WSN_PAN_ID;

    /* General initialisation */
    vInit();

    /* No return from the above function call */
}
Ejemplo n.º 6
0
Cstress::Cstress(Cimage_header& oHeader)
{
    vInit();

    // Read number of Z positions
    oHeader.nGetValue(Cstring(D_K_StressNumOfZPositions), &m_nNumOfZPositions);
    oHeader.nGetValue(Cstring(D_K_StressSlitWidth), &m_nSlitWidth);
    oHeader.nGetValue(Cstring(D_K_StressInclinationType), &m_sInclinationType);
    
    oHeader.nGetValue(Cstring(D_K_StressZPositions), m_anZPositions, " ");
    oHeader.nGetValue(Cstring(D_K_StressPsiAngles), m_afPsiAngles, " ");

    oHeader.nGetValue(Cstring(D_K_StressPeakAngle), &m_fPeakAngle);
    oHeader.nGetValue(Cstring(D_K_StressYoungModulus), &m_fYoungModulus);
    oHeader.nGetValue(Cstring(D_K_StressPoissonRatio), &m_fPoissonRatio);
    oHeader.nGetValue(Cstring(D_K_StressStressConstant), &m_fStressConstant);
}
Ejemplo n.º 7
0
/*****************************************************************************
 *  FUNCTION IMPLEMENTATIONS
 *****************************************************************************/
int main(void)
{
    /* One-time initialization of hardware */
    vInit();

    SchedulerInit(TICKS_PER_SECOND);

    char statusStr[96];

    int sounddemo=0; // sound demo
    SoundVolumeSet(80); // less obnoxious during testing


    while (1)
    {
        SchedulerRun();

        // to get measurements
        // currentMeasuredDistance

        // to play sound
        // soundStart(sounddemo) where soundemo is 0-9

        // A DEMO OF SOUNDS
       ///////////////////////////////////////////////////
        if(GamepadButtons.buttonA && bWavPlaying==false)
        {
        	usprintf(statusStr,"sound=%d\r",sounddemo);
        	Display96x16x1StringDrawCentered(statusStr,0,false);
        	sounddemo = soundStart(sounddemo); // returns the actual sound index used
        	sounddemo++;
        }
    }

    /* This should never happen */
    return 0;
}
Ejemplo n.º 8
0
/************************************************************************************************
* Bouncher moving                                                                               *
************************************************************************************************/
void cBouncher::Move(float mx, float my, float mz)
{
    this->Pos = vAdd(this->Pos, vInit(mx, my, mz));
}
Ejemplo n.º 9
0
CstrategyScan::CstrategyScan()
{
    vInit();
}
Ejemplo n.º 10
0
CstrategyScan::CstrategyScan(Cimage_header* poHeader, int nScanIndex, int nNumAxes, const Cstring& sStrategyPrefix)
{
    vInit();

    // Get gonio values
    
    // Build scan prefix
    Cstring         strScanCrystalPrefix = sBuildStrategyScanPrefix(sStrategyPrefix, D_K_CrystalPrefix, nScanIndex);

    double*         pdGonioValues = new double[nNumAxes];
    int             nStat = poHeader->nGetValue(strScanCrystalPrefix + D_K_GonioValues, nNumAxes, pdGonioValues);
    
    if( 0 != nStat )
    {
        delete [] pdGonioValues;
        return;
    }

    // Add axes objects 
    for(int ii=0; ii < nNumAxes; ii++)
    {
        m_aoAxes.push_back(CstrategyAxis(ii, pdGonioValues[ii]));
    }

    delete [] pdGonioValues;
    ///////////////////////////

    Cstring     sScanPrefix = sBuildStrategyScanPrefix(sStrategyPrefix, D_K_ScanPrefix, nScanIndex);
    Crotation     oRotation(*poHeader, sScanPrefix);
    
    m_dRot_Begin[enSingleScan] = m_dRot_Begin[enMultipleScan] = (double)oRotation.fGetRotStart();
    m_dRot_End  [enSingleScan] = m_dRot_End  [enMultipleScan] = (double)oRotation.fGetRotEnd();
    
    m_dMaxRotRange = (double)oRotation.fGetRotRange();

    m_segRotLimits.vSet((double)oRotation.fGetRotMin(), (double)oRotation.fGetRotMax());
    
    m_nOriginalScanIndex = nScanIndex;

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // See if the header uses D_K_ScanDetDatum keyword to specify the detector position. If it does not - no problem,
    // the detector position will be read by the container class CstrategyScans using detector D_K_GonioValues keyword.  
    Cstring     sScanDetRelZero(D_K_ScanDetDatum);

    double      dDetRelZero[3] = {0.0};
    if( 0 == poHeader->nGetValue(sScanPrefix + sScanDetRelZero, 3, dDetRelZero) ) // the first value should be equal to 2, then two theta and distance
    {
        m_dDetRelZero[enStratScanDetRelZero_TwoTheta] = dDetRelZero[1];
        m_dDetRelZero[enStratScanDetRelZero_Distance] = dDetRelZero[2];
    }


	///////////////////////////
	//shijie yao : 2008.03.12
	//Noticed there was a var m_fImageRotWidth defined, which should server the 
	//same as m_dIncrementalWidth. But the original code didn't set its value
	//properly. It's value was set from the STRATEGY_INPUT_S*_SCAN_ROTATION,
	//which only keeps the original copy of the SCAN_ROTATION values, even the
	//-rotimage option is provided.
	//After adding code in CDTMainMultiStrategy::bGetImageRotationWidth() to
	//update the STRATEGY_INPUT_S*_SCAN_ entries together with the SCAN_ROTATION,
	//for the new imagewidth value, m_fImageRotWidth and m_dIncrementalWidth are 
	//sequal now. 
	//
	m_fImageRotWidth = oRotation.fGetIncrement();
	m_dCryGonioValMax = oRotation.fGetRotMax();
	m_dCryGonioValMin = oRotation.fGetRotMin();
	//Crotation  oScanRot(*poHeader, D_K_ScanPrefix);	// use SCAN_ROTATION values for rotImageWidth
	//m_dIncrementalWidth = oScanRot.fGetIncrement();
}
Ejemplo n.º 11
0
void InitBeam(void)
// initialize beam; produce description string
{
	double w0; // beam width
	/* TO ADD NEW BEAM
	 * Add here all intermediate variables, which are used only inside this function.
	 */

	// initialization of global option index for error messages
	opt=opt_beam;
	// beam initialization
	switch (beamtype) {
		case B_PLANE:
			if (IFROOT) strcpy(beam_descr,"plane wave");
			beam_asym=false;
			if (surface) {
				if (prop_0[2]==0) PrintError("Ambiguous setting of beam propagating along the surface. Please specify "
					"the incident direction to have (arbitrary) small positive or negative z-component");
				if (msubInf && prop_0[2]>0) PrintError("Perfectly reflecting surface ('-surf ... inf') is incompatible "
					"with incident direction from below (including the default one)");
				// Here we set ki,kt,ktVec and propagation directions prIncRefl,prIncTran
				if (prop_0[2]>0) { // beam comes from the substrate (below)
					// here msub should always be defined
					inc_scale=1/creal(msub);
					ki=msub*prop_0[2];
					/* Special case for msub near 1 to remove discontinuities for near-grazing incidence. The details
					 * are discussed in CalcFieldSurf() in crosssec.c.
					 */
					if (cabs(msub-1)<ROUND_ERR && fabs(ki)<SQRT_RND_ERR) kt=ki;
					else kt=cSqrtCut(1 - msub*msub*(prop_0[0]*prop_0[0]+prop_0[1]*prop_0[1]));
					// determine propagation direction and full wavevector of wave transmitted into substrate
					ktVec[0]=msub*prop_0[0];
					ktVec[1]=msub*prop_0[1];
					ktVec[2]=kt;
				}
				else if (prop_0[2]<0) { // beam comes from above the substrate
					inc_scale=1;
					vRefl(prop_0,prIncRefl);
					ki=-prop_0[2];
					if (!msubInf) {
						// same special case as above
						if (cabs(msub-1)<ROUND_ERR && fabs(ki)<SQRT_RND_ERR) kt=ki;
						else kt=cSqrtCut(msub*msub - (prop_0[0]*prop_0[0]+prop_0[1]*prop_0[1]));
						// determine propagation direction of wave transmitted into substrate
						ktVec[0]=prop_0[0];
						ktVec[1]=prop_0[1];
						ktVec[2]=-kt;
					}
				}
				else LogError(ONE_POS,"Ambiguous setting of beam propagating along the surface. Please specify the"
					"incident direction to have (arbitrary) small positive or negative z-component");
				vRefl(prop_0,prIncRefl);
				if (!msubInf) {
					vReal(ktVec,prIncTran);
					vNormalize(prIncTran);
				}
			}
			return;
		case B_DIPOLE:
			vCopy(beam_pars,beam_center_0);
			if (surface) {
				if (beam_center_0[2]<=-hsub)
					PrintErrorHelp("External dipole should be placed strictly above the surface");
				inc_scale=1; // but scaling of Mueller matrix is weird anyway
			}
			// in weird scenarios the dipole can be positioned exactly at the origin; reused code from Gaussian beams
			beam_asym=(beam_center_0[0]!=0 || beam_center_0[1]!=0 || beam_center_0[2]!=0);
			if (!beam_asym) vInit(beam_center);
			/* definition of p0 is important for scaling of many scattering quantities (that are normalized to incident
			 * irradiance). Alternative definition is p0=1, but then the results will scale with unit of length
			 * (breaking scale invariance)
			 */
			p0=1/(WaveNum*WaveNum*WaveNum);
			if (IFROOT) sprintf(beam_descr,"point dipole at "GFORMDEF3V,COMP3V(beam_center_0));
			return;
		case B_LMINUS:
		case B_DAVIS3:
		case B_BARTON5:
			if (surface) PrintError("Currently, Gaussian incident beam is not supported for '-surf'");
			// initialize parameters
			w0=beam_pars[0];
			TestPositive(w0,"beam width");
			vCopy(beam_pars+1,beam_center_0);
			beam_asym=(beam_Npars==4 && (beam_center_0[0]!=0 || beam_center_0[1]!=0 || beam_center_0[2]!=0));
			if (!beam_asym) vInit(beam_center);
			s=1/(WaveNum*w0);
			s2=s*s;
			scale_x=1/w0;
			scale_z=s*scale_x; // 1/(k*w0^2)
			// beam info
			if (IFROOT) {
				strcpy(beam_descr,"Gaussian beam (");
				switch (beamtype) {
					case B_LMINUS:
						strcat(beam_descr,"L- approximation)\n");
						break;
					case B_DAVIS3:
						strcat(beam_descr,"3rd order approximation, by Davis)\n");
						break;
					case B_BARTON5:
						strcat(beam_descr,"5th order approximation, by Barton)\n");
						break;
					default: break;
				}
				sprintf(beam_descr+strlen(beam_descr),"\tWidth="GFORMDEF" (confinement factor s="GFORMDEF")\n"
				                                      "\tCenter position: "GFORMDEF3V,w0,s,COMP3V(beam_center_0));
			}
			return;
		case B_READ:
			// the safest is to assume cancellation of all symmetries
			symX=symY=symZ=symR=false;
			if (surface) inc_scale=1; // since we can't know it, we assume the default case
			if (IFROOT) {
				if (beam_Npars==1) sprintf(beam_descr,"specified by file '%s'",beam_fnameY);
				else sprintf(beam_descr,"specified by files '%s' and '%s'",beam_fnameY,beam_fnameX);
			}
			// we do not define beam_asym here, because beam_center is not defined anyway
			return;
	}
	LogError(ONE_POS,"Unknown type of incident beam (%d)",(int)beamtype);
	/* TO ADD NEW BEAM
	 * add a case above. Identifier ('B_...') should be defined inside 'enum beam' in const.h. The case should
	 * 1) save all the input parameters from array 'beam_pars' to local variables (defined in the beginning of this
	 *    source files)
	 * 2) test all input parameters (for that you're encouraged to use functions from param.h since they would
	 *    automatically produce informative output in case of error).
	 * 3) the symmetry breaking due to prop or beam_center is taken care of in VariablesInterconnect() in param.c.
	 *    But if there are other reasons why beam would break any symmetry, corresponding variable should be set to
	 *    false here. Do not set any of them to true, as they can be set to false by other factors.
	 *    symX, symY, symZ - symmetries of reflection over planes YZ, XZ, XY respectively.
	 *    symR - symmetry of rotation for 90 degrees over the Z axis
	 * 4) initialize the following:
	 *    beam_descr - descriptive string, which will appear in log file.
	 *    beam_asym - whether beam center does not coincide with the reference frame origin. If it is set to true, then
	 *                set also beam_center_0 - 3D radius-vector of beam center in the laboratory reference frame (it
	 *                will be then automatically transformed to particle reference frame, if required).
	 * 5) Consider the case of surface (substrate near the particle). If the new beam type is incompatible with it, add
	 *    an explicit exception, like "if (surface) PrintErrorHelp(...);". Otherwise, you also need to define inc_scale.
	 * All other auxiliary variables, which are used in beam generation (GenerateB(), see below), should be defined in
	 * the beginning of this file. If you need temporary local variables (which are used only in this part of the code),
	 * define them in the beginning of this function.
	 */
}
Ejemplo n.º 12
0
Cstress::Cstress()
{
    vInit();
}