public void Render() { if (sampler != null) { for (int i = 0; i < camera.ScreenWidth; i++) { for (int j = threadId; j < camera.ScreenHeight; j += Constants.NumberOfThreads) { Color pixelColor = new Color(0, 0, 0); List <List <Sample> > subPathSamples = new List <List <Sample> >(); List <Sample> samples = sampler.CreateSamples(); List <LightSample> lightSamples = new List <LightSample>(); if (integrator is PathTraceIntegrator) { lightSamples = sampler.GetLightSamples(Constants.MaximalPathLength); for (int s = 0; s < Constants.MaximalPathLength; s++) { subPathSamples.Add(sampler.CreateSamples()); } foreach (Sample sample in samples) { Ray ray = camera.CreateRay(i + sample.X, j + sample.Y); pixelColor.Append(integrator.Integrate(ray, objects, lights, sampler, subPathSamples, Randomizer.PickRandomLightSample(lightSamples))); } } else { lightSamples = sampler.GetLightSamples(); foreach (Sample sample in samples) { Ray ray = camera.CreateRay(i + sample.X, j + sample.Y); pixelColor.Append(integrator.Integrate(ray, objects, lights, sampler, subPathSamples, Randomizer.PickRandomLightSample(lightSamples))); } } pixelColor.VoidDiv(samples.Count); film.SetPixel(i, j, pixelColor); } } } else { for (int i = 0; i < camera.ScreenWidth; i++) { for (int j = threadId; j < camera.ScreenHeight; j += Constants.NumberOfThreads) { Ray ray = camera.CreateRay(i, j); Color pixelColor = integrator.Integrate(ray, objects, lights, null, null, null); film.SetPixel(i, j, pixelColor); } } } ThreadDone(this, new EventArgs()); }
public void FastTick(double updateTime, int microSteps) { for (int j = 0; j < microSteps; j++) { TerminalGuidanceThrust(updateTime / microSteps, ref _currentState, _currentState.Position.Length); _integrator.Integrate(updateTime / microSteps, ref _currentState, out _currentState, ComputeCurrentAcceleration); _currentState.ReachedAltitude = Math.Max(_currentState.ReachedAltitude, _currentAltitude); if (_currentAltitude < -0.1) { _currentState.IsDone = true; } } LookAhead.CalculateOrbit(ref LookAheadState, _currentState); }
public DistanceCalculatorOutput Calculate() { var state = new AircraftState(); bool hasFailureOccurred = false; int failureSpeed = calculationSettings.FailureSpeed; for (int i = 0; i < calculationSettings.MaximumNrOfTimeSteps; i++) { AircraftAccelerations accelerations = hasFailureOccurred ? failureTakeOffDynamicsCalculator.Calculate(state) : normalTakeOffDynamicsCalculator.Calculate(state); state = integrator.Integrate(state, accelerations, calculationSettings.TimeStep); if (state.TrueAirspeed > failureSpeed) { hasFailureOccurred = true; } if (state.Height >= screenHeight || state.TrueAirspeed <= 0) { if (!hasFailureOccurred) { throw new CalculatorException(Resources.DistanceCalculator_Calculation_converged_before_failure); } return(new DistanceCalculatorOutput(failureSpeed, state.Distance)); } } throw new CalculatorException(Resources.DistanceCalculator_No_calculation_convergence); }
/// <summary> /// Computes the integral of the current function over the specified interval. /// </summary> /// <param name="a">Lower integration limit.</param> /// <param name="b">Upper integration limit.</param> /// <returns>The integral value over the specified interval.</returns> /// <remarks> /// If an integrator was not explicitly set, the method uses the default integrator. /// </remarks> public double Integrate(double a, double b) { if (_integrator == null) { return(DefaultIntegrator.Integrate(_function, a, b)); } else { return(_integrator.Integrate(_function, a, b)); } }
/// <summary> /// Computes the integral of the current function over the specified interval. /// </summary> /// <param name="a">Lower integration limit.</param> /// <param name="b">Upper integration limit.</param> /// <returns>The integral value over the specified interval.</returns> /// <remarks> /// If an integrator was not explicitly set, the method uses the default integrator. /// </remarks> public float Integrate(float a, float b) { if (_integrator == null) { return(DefaultIntegrator.Integrate(_function, a, b)); } else { return(_integrator.Integrate(_function, a, b)); } }
public void Step() { ComputeForces(); if (m_Integrator != null) { m_Integrator.Integrate(this); } else { //IntegrateVerlet(); IntegrateEuler(); } //Collides(); }
public void Run(ITestSet tests, IIntegrator integrator, double targetError) { listView1.Items.Clear(); var summary = new TestSummary(tests, integrator, targetError); var functions = tests.GetTestFunctions(); int total = 0, failed = 0; Util.Tic(); foreach (var item in functions) { total++; try { var value = integrator.Integrate(item, targetError); Console.WriteLine(value); var result = GetTestResult(item, value); ShowTestResult(result, targetError); summary.Add(result); if (result.HasInvalidValue()) { failed++; } } catch (Exception e) { ProcessError(item, e); failed++; } } summary.Time = Util.Toc(); summary.TotalCount = total; summary.FailedCount = failed; ShowTestSummary(summary); }
/// <summary> /// Run the simulator for one timestep. /// </summary> /// <param name="timestep">the span of the timestep for which to run the simulator</param> public void RunSimulator(long timestep) { Accumulate(); mIntegrator.Integrate(this, timestep); }
/// <summary> /// Simulates the movement. /// </summary> /// <param name='dt'> /// Size of the time step /// </param> /// <param name='solver'> /// Used <see cref="ISolver"/> /// </param> public void SimulateMovement(double dt, IIntegrator integrator) { IntegratorResult ir = integrator.Integrate (LinearAcceleration, AngularAcceleration, LinearVelocity, AngularVelocity, dt); LinearVelocity += ir.DeltaLinearVelocity; CenterOfMass += ir.DeltaCenterOfMass; AngularVelocity += ir.DeltaAngularVelocity; AnglesOfRotation += ir.DeltaAnglesOfRotation; }