public static float Difference(Rotation2 r1, Rotation2 r2) { var higher = Math.Max(r1.Degrees, r2.Degrees); var lower = Math.Min(r1.Degrees, r2.Degrees); return(higher - lower); }
public Transform2(Vector2 location, Rotation2 rotation, Size2 size, float scale, int zIndex) { Location = location; Rotation = rotation; Size = size; Scale = scale; ZIndex = zIndex; }
public static Transform2 Lerp(Transform2 t1, Transform2 t2, float amount) { return(new Transform2( Vector2.Lerp(t1.Location, t2.Location, amount), Rotation2.Lerp(t1.Rotation, t2.Rotation, amount), Size2.Lerp(t1.Size, t2.Size, amount), MathHelper.Lerp(t1.Scale, t2.Scale, amount), Convert.ToInt32(MathHelper.Lerp(t1.ZIndex, t2.ZIndex, amount)))); }
public Rotation2 ToCardinal(Rotation2 previousCardinalRotation) { var degrees = (int)Degrees; if (315 < degrees || degrees < 45) { return(Rotation2.Up); } if (45 < degrees && degrees < 135) { return(Rotation2.Right); } if (135 < degrees && degrees < 225) { return(Rotation2.Down); } if (225 < degrees && degrees < 315) { return(Rotation2.Left); } if (degrees == 45) { return(Math.Abs(previousCardinalRotation.Degrees) < 0.01 ? Rotation2.Right : Rotation2.Up); } if (degrees == 135) { return(Math.Abs(previousCardinalRotation.Degrees - 180) < 0.01 ? Rotation2.Right : Rotation2.Down); } if (degrees == 225) { return(Math.Abs(previousCardinalRotation.Degrees - 180) < 0.01 ? Rotation2.Left : Rotation2.Down); } if (degrees == 315) { return(Math.Abs(previousCardinalRotation.Degrees) < 0.01 ? Rotation2.Left : Rotation2.Up); } throw new Exception("The developer made a horrible mistake if you see this!"); }
public Transform2(Vector2 location, Rotation2 rotation, Size2 size, float scale) : this(location, rotation, size, scale, 0) { }
public Transform2(Vector2 location, Rotation2 rotation, float scale) : this(location, rotation, Size2.Zero, scale) { }
public Transform2(Rotation2 rotation) : this(Vector2.Zero, rotation, Size2.Zero, 1) { }
public Transform2(Vector2 location, Rotation2 rotation, Size2 size, float scale, int zIndex) : this(location, rotation, size, scale, new ZIndex(zIndex)) { }
public static Rotation2 Lerp(Rotation2 r1, Rotation2 r2, float amount) { var degrees = Difference(r1, r2); return(new Rotation2(r1.Degrees + (amount * degrees))); }