예제 #1
0
//return Pressure, Velocity, Density
Real4 HalfProblemShockWave(Real PressureOut, Real VelocityOut, Real DensityOut,
		Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real WaveSpeed;
	Real4 Result;
	Real DPressure = PressureContact / PressureOut;
	if (fabs(1 - DPressure) < Epsilon)
		WaveSpeed = VelocityOut - SoundOut;
	else {
		Real DGamma = (GammaOut - 1) / (2 * GammaOut);
		WaveSpeed = VelocityOut - DGamma * SoundOut * (1 - DPressure) / (1
				- pow(DPressure, DGamma));
	};
	if (WaveSpeed >= 0) {
		Pressure(Result) = PressureOut;
		Velocity(Result) = VelocityOut;
		Density(Result) = DensityOut;
	} else {
		Pressure(Result) = PressureContact;
		Velocity(Result) = VelocityContact;
		Density(Result) = DensityOut * ((GammaOut + 1) * PressureContact
				+ (GammaOut - 1) * PressureOut) / ((GammaOut - 1)
				* PressureContact + (GammaOut + 1) * PressureOut);
	};
	return Result;
}
KOKKOS_INLINE_FUNCTION
void Hydrostatic_Velocity<EvalT, Traits>::
operator() (const Hydrostatic_Velocity_PRESCRIBED_1_1_Tag& tag, const int& cell) const{
  for (int node=0; node < numNodes; ++node) {
    const MeshScalarT lambda = sphere_coord(cell, node, 0);
    const MeshScalarT theta = sphere_coord(cell, node, 1);
    ScalarT lambdap = lambda - 2.0*PI*time/tau;

    ScalarT Ua = k*sin(lambdap)*sin(lambdap)*sin(2.0*theta)*cos(PI*time/tau)
               + (2.0*PI*earthRadius/tau)*cos(theta);

    ScalarT Va = k*sin(2.0*lambdap)*cos(theta)*cos(PI*time/tau);

    for (int level=0; level < numLevels; ++level) {
      ScalarT B = this->B(level);
      ScalarT p = pressure(cell,node,level);

      ScalarT taper = - exp( (p    - p0)/(B*ptop) )
                      + exp( (ptop - p )/(B*ptop) );

      ScalarT Ud = (omega0*earthRadius)/(B*ptop)
                   *cos(lambdap)*cos(theta)*cos(theta)*cos(2.0*PI*time/tau)*taper;

      Velocity(cell,node,level,0) = Ua + Ud; 
      Velocity(cell,node,level,1) = Va; 
    }
  }
}
예제 #3
0
//return Pressure, Velocity, Density
Real4 HalfProblemDepressionWave(Real PressureOut, Real VelocityOut,
		Real DensityOut, Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real4 Result;
	Real WaveLeftBoundarySpeed = VelocityOut - SoundOut,
			WaveRightBoundarySpeed = VelocityContact * Real(0.5) * (1
					+ GammaOut) - VelocityOut * Real(0.5) * (GammaOut - 1)
					- SoundOut;
	if (WaveLeftBoundarySpeed > 0) {
		Pressure(Result) = PressureOut;
		Velocity(Result) = VelocityOut;
		Density(Result) = DensityOut;
	} else {
		Real SoundContact = SoundOut + Real(0.5) * (GammaOut - 1)
				* (VelocityOut - VelocityContact);
		Real DensityContact = GammaOut * PressureContact / Sqr(SoundContact);
		if (WaveRightBoundarySpeed < 0) {
			Velocity(Result) = VelocityContact;
			Pressure(Result) = PressureContact;
			Density(Result) = DensityContact;
		} else {
			Real Ratio = WaveLeftBoundarySpeed / (WaveLeftBoundarySpeed
					- WaveRightBoundarySpeed);
			Pressure(Result) = PressureOut + (PressureContact - PressureOut)
					* Ratio;
			Density(Result) = DensityOut + (DensityContact - DensityOut)
					* Ratio;
			Velocity(Result) = VelocityOut + (VelocityContact - VelocityOut)
					* Ratio;
		};
	};
	return Result;
}
예제 #4
0
TEST_F(SettingsTest, AddSettingVelocity)
{
    settings.add("test_setting", "12.345");
    EXPECT_DOUBLE_EQ(Velocity(12.345), settings.get<Velocity>("test_setting"));

    settings.add("test_setting", "-78");
    EXPECT_DOUBLE_EQ(Velocity(-78), settings.get<Velocity>("test_setting"));
}
예제 #5
0
double alphapm(double* Ui, double* Uimo, int pm, double  Pi, double Pimo){
  double vi = Velocity(Ui); double ci = C_s(Pi, Ui[0]);
  double lami = lambdapm(vi, ci, pm);
  double vimo = Velocity(Uimo); double cimo = C_s(Pimo, Uimo[0]);
  double lamimo = lambdapm(vimo, cimo, pm);
  double tobemaxed[3] = {0, (double)pm*lami, (double)pm*lamimo};
  double alpha = Max(tobemaxed, 3);
  //printf("%f  %f\n", lami, lamimo);
  return(alpha);
}
예제 #6
0
//return Pressure, Velocity, Density, Energy
Real4 CaseNotVacuum(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	Real2 Contact = NewtonVelocity(PressureLeft, VelocityLeft, DensityLeft,
			GammaLeft, SoundLeft, PressureRight, VelocityRight, DensityRight,
			GammaRight, SoundRight);
	if (Velocity(Contact) > 0)
		return SolveHalfProblem(PressureLeft, VelocityLeft, DensityLeft,
				GammaLeft, SoundLeft, Pressure(Contact), Velocity(Contact),
				true);
	else
		return SolveHalfProblem(PressureRight, VelocityRight, DensityRight,
				GammaRight, SoundRight, Pressure(Contact), Velocity(Contact),
				false);
}
예제 #7
0
 virtual void Execute(NodeArguments* args) {
   if (args->IsInputDirty(0)) {
     auto entity = args->GetInput<EntityRef>(1);
     auto physics_data = physics_component_->GetComponentData(*entity);
     args->SetOutput(0, physics_data->Velocity());
   }
 }
void Pellet::Update()
{
  if (!HasImpacted())
  {
     //calculate the steering force
    Vector2D DesiredVelocity = Vec2DNormalize(m_vTarget - Pos()) * MaxSpeed();

    Vector2D sf = DesiredVelocity - Velocity();

    //update the position
    Vector2D accel = sf / m_dMass;

    m_vVelocity += accel;

    //make sure vehicle does not exceed maximum velocity
    m_vVelocity.Truncate(m_dMaxSpeed);

    //update the position
    m_vPosition += m_vVelocity; 

    TestForImpact();
  }
  else if (!isVisibleToPlayer())
  {
    m_bDead = true;
  }
}
예제 #9
0
bool FusionLocalAlgoTest1(FusionInput &input, FusionOutput &output)
{
    // This is how to use global var.
    g_GlobalVar[0].m_G[0] = 0;
    g_GlobalVar[0].m_G[1] = 0;
    map<SensorId, NoiseDataPacket> &noiseDatas = input.m_NoiseDataPackets;
    int interval = input.m_Interval;

    int nTargets = noiseDatas[SensorIdRadar].m_TargetNoiseDatas.size();
    for (int iTarget = 0; iTarget < nTargets; ++iTarget)
    {
        TrueDataFrame frame;
        frame.m_Time = noiseDatas[SensorIdRadar].m_TargetNoiseDatas[iTarget].m_Time;
        frame.m_Id = 100 + iTarget + frame.m_Time / 100 * 100;
        frame.m_Type = iTarget % TargetTypeLast;
        for (int iSensor = SensorIdRadar; iSensor < SensorIdLast; ++iSensor)
        {
            // frame += noiseDatas[(SensorId)iSensor].m_TargetNoiseDatas[iTarget];
        }
        frame.m_Pos = Position(800 - frame.m_Time, 100 + iTarget * 250, 100);
        frame.m_Vel = Velocity(-1, 0, 0);
        frame.m_IsKeyTarget = iTarget % 2 ? true : false;
        // frame /= SensorIdLast;
        output.m_FusionDataPacket.m_FusionDatas.push_back(frame);
        // frame = noiseDatas[SensorIdRadar].m_TargetNoiseDatas[iTarget];
    }

    return true;
}
예제 #10
0
Imu::Imu(ConfigFileWrapper& configFileWrapper) :_configFileWrapper(configFileWrapper)
{
    _rate = Rate();
    _angle = Angle();
    _velocity = Velocity();
    
    _accelZeroPitch = _configFileWrapper.getAccelZeroPitch();
    _accelZeroRoll = _configFileWrapper.getAccelZeroRoll();
    
    Thread::wait(500);
    _freeImu.init(true);
    Thread::wait(500);
    
    _barometerZeroFilter = new filter(100);
    _barometerFilter = new filter(50);
    _barometerZero = 0;
    zeroBarometer();
    
    
    _kalmanXVelFilter = new Kalman(0.1, 32, 1, 0);
    _kalmanYVelFilter = new Kalman(0.1, 32, 1, 0);
    _kalmanZVelFilter = new Kalman(0.1, 32, 1, 0);
    
    DEBUG("IMU initialised\r\n");
}
예제 #11
0
파일: Weapon.cpp 프로젝트: waddy500/qsg
void Weapon::Update(float elapsedTime)
{
	Entity* bullet;
	if ((elapsedTime + m_frequencyCount) * m_frequency >= 1)
	{
		int x = (elapsedTime + m_frequencyCount) * (float) m_frequency;
		m_frequencyCount = 0;

		for (int i = 0; i < x; i++)
		{
			bullet = new Entity(m_parent->GetParent());

			bullet->SetPosition(sf::Vector2f(GetParent()->GetPosition().x,
					GetParent()->GetPosition.y()));

			sf::Vector2f Velocity(cos(0) * m_speed, sin(0) * m_speed);

			bullet->SetPhysicsComponent(new PhysicsComponent(m_parent->GetParent()));

			bullet->GetPhysicsComponent()->SetColisionCircle(10);

            bullet->GetPhysicsComponent()->SetVelocity(Velocity.x, Velocity.y);


			entityManager->AddEntity(bullet);
		}
	}
}
void ParticleEmitterComponent::update(double time) {

  auto last_spawn_position = math::get_translation(WorldTransform());

  TransformableComponent::update(time);
  Density.update(time);

  if (!ParticleSystem) {
    ParticleSystem = get_user()->get_component<ParticleSystemComponent>(ParticleSystemLabel());
  }

  if (ParticleSystem) {
    particles_to_spawn_ += time * Density();

    if (particles_to_spawn_ > 1.f) {
      auto pos(math::get_translation(WorldTransform()));
      auto rot(math::get_rotation(WorldTransform()));

      int count = particles_to_spawn_;
      particles_to_spawn_ = particles_to_spawn_ - count;

      for (int i(0); i<count; ++i) {
        auto p = pos + 1.f*i/count*(last_spawn_position-pos);
        ParticleSystem->spawn(p, rot, Velocity());
      }
    }
  }
}
예제 #13
0
Ship::Ship()
{
  this-> setAlive(true);
  this-> setRotation(0);
  this-> setPoint(Point(50,50));
  this-> setThrust(false);
  this-> setVelocity(Velocity(0,0));
}
예제 #14
0
TEST(DestinationPoint, GoStraightEast) {
    GeographicCoordinate coord1 (16, 16, 25000);
    Velocity vel (100, 100, 100);
    //GeographicCoordinate dest = GenerationMath::DestinationPoint(coord1, vel, 90);
    //std::cout << "\n" << dest.GetLatitude() << " " << dest.GetLongitude() << std::endl;
    //ASSERT_NEAR(16.00, dest.GetLatitude(),.005);
    //ASSERT_NEAR(16.004, dest.GetLongitude(),.005);

    //GeographicCoordinate coord2 (123, 24, 345);
    GeographicCoordinate coord2 (50, 60, 100);
    GeographicCoordinate final = GenerationMath::DestinationPoint(coord2, Velocity(34, 0, 23), 270);
    //std::cout << "lat: " << final.GetLatitude() << " long: " << final.GetLongitude() << std::endl;

    GeographicCoordinate coord3 (89, 131, 345);
    GeographicCoordinate final2 = GenerationMath::DestinationPoint(coord3, Velocity(34, 0, 23), 270);
    //std::cout << "\nlat: " << final2.GetLatitude() << " long: " << final2.GetLongitude() << std::endl;
}
void RigidBodySimulator::HandleCollision(Physical_Object * first, Physical_Object * last){
	//
	Vec3f momentumFirstBefore = first->GetVelovity()*first->GetMass();
	Vec3f momentumSecondBefore = last->GetVelovity()*last->GetMass();

	Vec3f dis = first->getPosition() - last->getPosition();
	dis.normalize();

	float firstAfterSpeed = first->GetVelovity().getunifiedVector().length()*(first->GetMass() - last->GetMass()) / (first->GetMass() + last->GetMass()) + last->GetVelovity().getunifiedVector().length()*(last->GetMass() * 2) / (first->GetMass() + last->GetMass());
	float lastAfterSpeed = last->GetVelovity().getunifiedVector().length()*(first->GetMass() - last->GetMass()) / (first->GetMass() + last->GetMass()) + first->GetVelovity().getunifiedVector().length()*(first->GetMass() * 2) / (first->GetMass() + last->GetMass());

	Vec3f firstAftervelocity = (first->GetVelovity().getunifiedVector() - dis*first->GetVelovity().getunifiedVector().dot(dis) * 2).getNorm()*firstAfterSpeed;
	Vec3f lastAftervelocity = (last->GetVelovity().getunifiedVector() - dis*last->GetVelovity().getunifiedVector().dot(dis) * 2).getNorm()*lastAfterSpeed;

	first->SetVelocity(Velocity(firstAftervelocity));
	last->SetVelocity(Velocity(lastAftervelocity));
}
KOKKOS_INLINE_FUNCTION
void Hydrostatic_Velocity<EvalT, Traits>::
operator() (const Hydrostatic_Velocity_Tag& tag, const int& cell) const{
  for (int node=0; node < numNodes; ++node) 
    for (int level=0; level < numLevels; ++level) 
      for (int dim=0; dim < numDims; ++dim)  
        Velocity(cell,node,level,dim) = Velx(cell,node,level,dim); 
}
예제 #17
0
//return Pressure, Velocity, Density
Real4 HalfProblemContactDiscontinuty(Real PressureOut, Real VelocityOut,
		Real DensityOut, Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real4 Result;
	Pressure(Result) = PressureContact;
	Density(Result) = DensityOut;
	Velocity(Result) = VelocityContact;
	return Result;
}
예제 #18
0
void GBRobot::EngineSeek(const GBVector & pos, const GBVector & vel) {
	GBVector delta = pos - Position();
	if ( vel.Zero() && (delta + Velocity() * 11).Norm() < radius )
		hardware.SetEnginePower(0);
	else {
		hardware.SetEnginePower(hardware.EngineMaxPower());
		hardware.SetEngineVelocity(vel + delta * GBNumber(0.09)); // FIXME: better seek
	}
}
예제 #19
0
//return Pressure and Velocity
Real2 NewtonVelocity(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	int CountIterations = 0;
	Real2 Result;
	Pressure(Result) = (-VelocityRight + VelocityLeft + SoundLeft / GammaLeft
			+ SoundRight / GammaRight) / (SoundLeft
			/ (GammaLeft * PressureLeft) + SoundRight / (GammaRight
			* PressureRight));
	Real IterateVelocityLeft = AdiabatVelocity(PressureLeft, VelocityLeft,
			DensityLeft, SoundLeft, GammaLeft, Pressure(Result), true),
			IterateVelocityRight = AdiabatVelocity(PressureRight,
					VelocityRight, DensityRight, SoundRight, GammaRight,
					Pressure(Result), false);
	while ((fabs(IterateVelocityLeft - IterateVelocityRight) > Epsilon * (fabs(
			IterateVelocityLeft) - fabs(IterateVelocityRight)))
			&& (CountIterations < 1000)) {
		Real DerivatLeft = AdiabatVelocityDerivative(PressureLeft,
				VelocityLeft, DensityLeft, SoundLeft, GammaLeft,
				Pressure(Result), true);
		Real DerivatRight = AdiabatVelocityDerivative(PressureRight,
				VelocityRight, DensityRight, SoundRight, GammaRight,
				Pressure(Result), false);
		Real PressureStep = -(IterateVelocityLeft - IterateVelocityRight)
				/ (DerivatLeft - DerivatRight);
		if (fabs(PressureStep / Pressure(Result)) < Epsilon)
			break;
		Pressure(Result) += PressureStep;
		IterateVelocityRight = AdiabatVelocity(PressureRight, VelocityRight,
				DensityRight, SoundRight, GammaRight, Pressure(Result), false);
		IterateVelocityLeft = AdiabatVelocity(PressureLeft, VelocityLeft,
				DensityLeft, SoundLeft, GammaLeft, Pressure(Result), true);
		CountIterations++;
	};


    #ifndef CUDA
	if (CountIterations >= 1000)
		Velocity(Result) = Real(CountIterations / 0);
    else
	#endif
		Velocity(Result) = Real(0.5) * (IterateVelocityLeft + IterateVelocityRight);
		return Result;
	};
예제 #20
0
void Ship::updateVelocity()
{
  float newDx = cos(this-> degreesToRadians(this-> getRotation() + 90));
  float newDy = sin(this-> degreesToRadians(this-> getRotation() + 90));
  Velocity newVelocity = Velocity(this-> getVelocity().getDx() +
				  newDx * 0.5,
				  this-> getVelocity().getDy() +
				  newDy * 0.5);
  this-> setVelocity(newVelocity);
}
예제 #21
0
//return Pressure, Velocity, Density, Energy
Real4 SolveHalfProblem(Real PressureOut, Real VelocityOut, Real DensityOut,
		Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact, bool Left) {
	Real Sign = Left ? Real(1) : Real(-1);
	Real4 Result;
	if (PressureOut > PressureContact)
		Result = HalfProblemDepressionWave(PressureOut, Sign * VelocityOut,
				DensityOut, GammaOut, SoundOut, PressureContact, Sign
						* VelocityContact);
	else if (PressureOut < PressureContact)
		Result = HalfProblemShockWave(PressureOut, Sign * VelocityOut,
				DensityOut, GammaOut, SoundOut, PressureContact, Sign
						* VelocityContact);
	else
		Result = HalfProblemContactDiscontinuty(PressureOut,
				Sign * VelocityOut, DensityOut, GammaOut, SoundOut,
				PressureContact, Sign * VelocityContact);
	Energy(Result) = Pressure(Result) / ((GammaOut - 1) * Density(Result));
	Velocity(Result) = Sign * Velocity(Result);
	return Result;
}
KOKKOS_INLINE_FUNCTION
void XZHydrostatic_Omega<EvalT, Traits>::
operator() (const XZHydrostatic_Omega_Tag& tag, const int& cell) const{
  for (int qp=0; qp < numQPs; ++qp) {
    for (int level=0; level < numLevels; ++level) {
      ScalarT                               sum  = -0.5*divpivelx(cell,qp,level) * delta(level);
      for (int j=0; j<level; ++j)           sum -=     divpivelx(cell,qp,j)     * delta(j);
      for (int dim=0; dim < numDims; ++dim) sum += Velocity(cell,qp,level,dim)*gradp(cell,qp,level,dim);
      omega(cell,qp,level) = sum/(Cpstar(cell,qp,level)*density(cell,qp,level));
    }
  }
}
예제 #23
0
  // TODO: Change to CreateSplineToTarget()
  void SetTarget(MotiveIndex index, const MotiveTarget1f& t) {
    SplineData& d = Data(index);

    // If the first node specifies time=0 or there is no valid data in the
    // interpolator, we want to override the current values with the values
    // specified in the first node.
    const MotiveNode1f& node0 = t.Node(0);
    const bool override_current =
        node0.time == 0 || !interpolator_.Valid(index);
    // TODO(b/65298927):  It seems that the animation pipeline can produce data
    // that is out of range.  Instead of just using node0.value directly, if
    // the interpolator is doing modular arithmetic, normalize the y value to
    // the modulator's range.
    const float start_y =
        override_current
            ? (interpolator_.ModularArithmetic(index)
                   ? interpolator_.ModularRange(index).Normalize(node0.value)
                   : node0.value)
            : interpolator_.NormalizedY(index);
    const float start_derivative =
        override_current ? node0.velocity : Velocity(index);
    const int start_node_index = override_current ? 1 : 0;

    // Ensure we have a local spline available, allocated from our pool of
    // splines.
    if (d.local_spline == nullptr) {
      d.local_spline = AllocateSpline();
    }

    // Initialize the compact spline to hold the sequence of nodes in 't'.
    // Add the first node, which has the start condition.
    const float end_x = static_cast<float>(t.EndTime());
    const Range y_range = CalculateYRange(index, t, start_y);
    const float x_granularity = CompactSpline::RecommendXGranularity(end_x);
    d.local_spline->Init(y_range, x_granularity);
    d.local_spline->AddNode(0.0f, start_y, start_derivative);

    // Add subsequent nodes, in turn, taking care to respect the 'direction'
    // request when using modular arithmetic.
    float prev_y = start_y;
    for (int i = start_node_index; i < t.num_nodes(); ++i) {
      const MotiveNode1f& n = t.Node(i);
      const float y = interpolator_.NextY(index, prev_y, n.value, n.direction);
      d.local_spline->AddNode(static_cast<float>(n.time), y, n.velocity,
                              motive::kAddWithoutModification);
      prev_y = y;
    }

    // Point the interpolator at the spline we just created. Always start our
    // spline at time 0.
    interpolator_.SetSplines(index, 1, d.local_spline, SplinePlayback());
  }
예제 #24
0
//return Pressure, Velocity, Density, Energy
Real4 CaseVacuum(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	Real4 Result;
	if (VelocityLeft - SoundLeft >= 0) {
		Density(Result) = DensityLeft;
		Pressure(Result) = PressureLeft;
		Velocity(Result) = VelocityLeft;
		Energy(Result) = Pressure(Result)
				/ ((GammaLeft - 1) * Density(Result));
	} else if (VelocityLeft + 2 * SoundLeft / (GammaLeft - 1) >= 0) {
		Real Ratio = 2 / (GammaLeft + 1);
		Density(Result) = DensityLeft * Ratio;
		Pressure(Result) = PressureLeft * Ratio;
		Velocity(Result) = VelocityLeft + SoundLeft * Ratio;
		Energy(Result) = Pressure(Result)
				/ ((GammaLeft - 1) * Density(Result));
	}
	if (VelocityRight + SoundRight <= 0) {
		Density(Result) = DensityRight;
		Pressure(Result) = PressureRight;
		Velocity(Result) = VelocityRight;
		Energy(Result) = Pressure(Result) / ((GammaRight - 1)
				* Density(Result));
	} else if (VelocityLeft - 2 * SoundRight / (GammaRight - 1) <= 0) {
		Real Ratio = 2 / (GammaRight + 1);
		Density(Result) = DensityRight * Ratio;
		Pressure(Result) = PressureRight * Ratio;
		Velocity(Result) = VelocityRight - SoundLeft * Ratio;
		Energy(Result) = Pressure(Result) / ((GammaRight - 1)
				* Density(Result));
	} else {
		Density(Result) = 0;
		Pressure(Result) = 0;
		Velocity(Result) = 0;
		Energy(Result) = 0;
	};
	return Result;
}
예제 #25
0
파일: Prediction.cpp 프로젝트: huner15/saas
Velocity Prediction::PredictVelocity(CorrelationAircraft *aircraft, bool is_relative) {
    Snapshot *last = _history->GetLast();
    Snapshot *second_to_last = _history->GetSecondToLast();

    CorrelationAircraft compare;

    SphericalCoordinate pos1;
    SphericalCoordinate pos2;

    Velocity predicted;

    if (is_relative && !second_to_last->GetAircraft()->empty()) {
        // For second to last snapshot
        for (int i = 0; i < second_to_last->GetAircraft()->size(); i++) {
            if (second_to_last->GetAircraft()->at(i).GetTcasID().Get() == aircraft->GetTcasID().Get()) {
                compare = second_to_last->GetAircraft()->at(i);
                pos1 = compare.GetSphericalCoordinate();
            }
        }

        // For last snapshot
        for (int i = 0; i < last->GetAircraft()->size(); i++) {
            if (last->GetAircraft()->at(i).GetTcasID().Get() == aircraft->GetTcasID().Get()) {
                compare = last->GetAircraft()->at(i);
                pos2 = compare.GetSphericalCoordinate();
            }
        }

        // Vector of aircraft from second to last snapshot
        Saas_Util::Vector<double, 3> vector1;
        vector1.x = pos1.GetRange() * sin(pos1.GetAzimuth()) * cos(pos1.GetElevation());
        vector1.y = pos1.GetRange() * cos(pos1.GetAzimuth()) * cos(pos1.GetElevation());
        vector1.z = -1 * pos1.GetRange() * sin(pos1.GetElevation());

        // Vector of aircraft from last snapshot
        Saas_Util::Vector<double, 3> vector2;
        vector1.x = pos2.GetRange() * sin(pos2.GetAzimuth()) * cos(pos1.GetElevation());
        vector1.y = pos2.GetRange() * cos(pos2.GetAzimuth()) * cos(pos1.GetElevation());
        vector1.z = -1 * pos2.GetRange() * sin(pos2.GetElevation());

        double time_diff = difftime(compare.GetTime(), aircraft->GetTime()); // seconds
        double east = (vector2.x - vector1.x) / time_diff;         // x
        double north = (vector2.y - vector1.y) / time_diff;        // y
        double down = (vector2.z - vector1.z) / time_diff;         // z

        // geodetic to cartesian
        predicted = Velocity(east, down, north);
    }

    return predicted;
}
예제 #26
0
파일: Particle.hpp 프로젝트: sfegan/ChiLA
 /*! Propagate particle by positive dist
   \param dist: propagation distance        [cm]
   
   \note 
   Returns 'true' if particle is propagated, and returns 'false'
   if particle is at rest
 */
 inline bool Particle::PropagateFree(double dist)
 {
   Vec3D beta=Velocity();
   double s=beta.Norm();
   
   if( s == 0 )      // do not propagate; particle is at rest       
     return false;
   
   double ct=dist/s;
   r.r+=ct*beta;
   r.r0+=ct;
   
   return true;
 }
예제 #27
0
double Entropy(double ** U, int NT, double dx, double * sumv, double * sump){
  double vsum = 0;
  double psum = 0;
  int i;for(i=1;i<NT-1;++i){
    double Ui[3]; getcol(U, i, Ui);
    double P = Pressure(Ui);
    double V = Velocity(Ui);
    double Pi = Pressurei(Ui[0]);
    double Vi = Velocityi(Ui[0]);
    vsum += dx*fabs(V - Vi);
    psum += dx*fabs(P - Pi);
  }
  *sumv = vsum; *sump = psum;
}
KOKKOS_INLINE_FUNCTION
void Hydrostatic_Velocity<EvalT, Traits>::
operator() (const Hydrostatic_Velocity_PRESCRIBED_1_2_Tag& tag, const int& cell) const{
  //FIXME: Pete, Tom - please fill in
  for (int node=0; node < numNodes; ++node) {
    const MeshScalarT lambda = sphere_coord(cell, node, 0);
    const MeshScalarT theta = sphere_coord(cell, node, 1);
    for (int level=0; level < numLevels; ++level) {
      for (int dim=0; dim < numDims; ++dim) {
        Velocity(cell,node,level,dim) = 0.0; //FIXME  
      }
    }
  }
}
예제 #29
0
파일: player.cpp 프로젝트: google/zooshi
corgi::EntityRef PlayerComponent::SpawnProjectile(corgi::EntityRef source) {
  const SushiConfig* current_sushi = static_cast<const SushiConfig*>(
      entity_manager_->GetComponent<ServicesComponent>()
          ->world()
          ->SelectedSushi()
          ->data());
  corgi::EntityRef projectile =
      entity_manager_->GetComponent<ServicesComponent>()
          ->entity_factory()
          ->CreateEntityFromPrototype(current_sushi->prototype()->c_str(),
                                      entity_manager_);
  GraphComponent* graph_component =
      entity_manager_->GetComponent<GraphComponent>();
  graph_component->EntityPostLoadFixup(projectile);

  TransformData* transform_data = Data<TransformData>(projectile);
  PhysicsData* physics_data = Data<PhysicsData>(projectile);
  PlayerProjectileData* projectile_data =
      Data<PlayerProjectileData>(projectile);

  TransformComponent* transform_component = GetComponent<TransformComponent>();
  transform_data->position =
      transform_component->WorldPosition(source) +
      mathfu::kAxisZ3f * config_->projectile_height_offset();
  auto forward = CalculateProjectileDirection(source);
  auto velocity = current_sushi->speed() * forward +
                  current_sushi->upkick() * mathfu::kAxisZ3f;
  transform_data->position +=
      velocity.Normalized() * config_->projectile_forward_offset();

  // Include the raft's current velocity to the thrown sushi.
  auto raft_entity =
      entity_manager_->GetComponent<ServicesComponent>()->raft_entity();
  auto raft_rail = raft_entity ? Data<RailDenizenData>(raft_entity) : nullptr;
  if (raft_rail != nullptr) velocity += raft_rail->Velocity();

  physics_data->SetVelocity(velocity);
  physics_data->SetAngularVelocity(RandomProjectileAngularVelocity());
  auto physics_component = entity_manager_->GetComponent<PhysicsComponent>();
  physics_component->UpdatePhysicsFromTransform(projectile);

  projectile_data->owner = source;

  // TODO: Preferably, this should be a step in the entity creation.
  transform_component->UpdateChildLinks(projectile);

  Data<AttributesData>(source)->attributes[AttributeDef_ProjectilesFired]++;

  return corgi::EntityRef();
}
예제 #30
0
파일: box.C 프로젝트: avoronts/hard_spheres
//==============================================================
// Velocity Giver, assigns initial velocities from Max/Boltz dist.
//==============================================================
void box::VelocityGiver(double T)
{
  for (int i=0; i<N; i++)
    {
      for (int k=0; k<DIM; k++)
	{
	  if (T==0.)
	    s[i].v[k] = 0.;
	  else
	    s[i].v[k] = Velocity(T);
            s[i].v0[k] = s[i].v[k];  // initial velocity !!!! add by A.Vorontsov   
            v0_sqr += s[i].v[k]*s[i].v[k]; // square of velocity !!!! add by A.Vorontsov
	}
    }
}