Simplify math by making direction a float

This commit is contained in:
Dean Herbert 2020-11-19 18:46:19 +09:00
parent dd5b90cf6c
commit 1c7ee2ca5f
1 changed files with 2 additions and 2 deletions

View File

@ -120,7 +120,7 @@ protected override void Blit(Action<TexturedVertex2D> vertexAction)
private readonly struct ParticlePart
{
private readonly double duration;
private readonly double direction;
private readonly float direction;
private readonly float distance;
public ParticlePart(double availableDuration)
@ -135,7 +135,7 @@ public ParticlePart(double availableDuration)
public Vector2 PositionAtTime(double time)
{
var travelledDistance = distance * progressAtTime(time);
return new Vector2(0.5f) + travelledDistance * new Vector2((float)Math.Sin(direction), (float)Math.Cos(direction));
return new Vector2(0.5f) + travelledDistance * new Vector2(MathF.Sin(direction), MathF.Cos(direction));
}
private float progressAtTime(double time) => (float)Math.Clamp(time / duration, 0, 1);