Files
CalamityModPublic/Utilities/Circle.cs
T
DominicKarma42 55e89c9b98 Replaced (hopefully) every magic number with a constant
Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
2020-05-30 17:56:36 -04:00

39 lines
975 B
C#

using Microsoft.Xna.Framework;
using System;
using Terraria;
namespace CalamityMod
{
public class Circle
{
public float Radius;
public Vector2 Center;
public Circle(Vector2 center, float radius)
{
this.Center = center;
this.Radius = radius;
}
private Vector2 RandomPointUnitCircle()
{
double r = Math.Sqrt(Main.rand.NextDouble());
double t = Main.rand.NextDouble() * MathHelper.TwoPi;
return new Vector2((float)(r * Math.Cos(t)), (float)(r * Math.Sin(t)));
}
public Vector2 RandomPointInCircle()
{
return Center + RandomPointUnitCircle() * Radius;
}
public Vector2 RandomPointOnCircleEdge()
{
Vector2 v = RandomPointUnitCircle();
//Normalise so point is on edge of unit circle
v.Normalize();
return Center + v * Radius;
}
}
}