protected float Integrate(Domain<TState> domain, Transition<TState> tr)
{
const int samples = 4;
var p1 = tr.From.Position;
var p2 = tr.To.Position;
var dp = p2 - p1;
float sum = 0;
for (float s = 0.5f; s < samples; s += 1) {
var t = s / samples;
var sample = p1 + t * dp;
sum += Math.Max(1f, Multiplier(sample));
}
var cost = domain.ComputeCost(tr.From.Position, tr.To.Position);
return cost * sum / samples;
}
More shortly.
Thursday, August 8, 2013
Multiplier Field Path Integration
A while ago I mentioned that I was approximating the integral of a transition in a multiplier field with the value of the multiplier field at the midpoint. I decided to finally change that, so I wrote a quick fixed step midpoint integration:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment