Add probabilistic sampling functions to WRange, WVec.

This commit is contained in:
Paul Chote
2013-07-07 18:40:46 +12:00
parent 46a384d1ca
commit 6d52af4553
2 changed files with 22 additions and 0 deletions

View File

@@ -69,6 +69,16 @@ namespace OpenRA
return new WVec(ret.X, ret.Y, ret.Z + offset);
}
// Sampled a N-sample probability density function in the range [-1024..1024, -1024..1024]
// 1 sample produces a rectangular probability
// 2 samples produces a triangular probability
// ...
// N samples approximates a true gaussian
public static WVec FromPDF(Thirdparty.Random r, int samples)
{
return new WVec(WRange.FromPDF(r, samples), WRange.FromPDF(r, samples), WRange.Zero);
}
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }
public override bool Equals(object obj)