Skip to content

Instantly share code, notes, and snippets.

View Vercidium's full-sized avatar

Vercidium Vercidium

View GitHub Profile
@Vercidium
Vercidium / armScaling.cs
Last active May 4, 2019 02:35
Arm Scaling
Vector3 GetPoint()
{
Vector3 v = Vector3.Zero;
// Generate a point
...
// Calculate the global angle of the point around the axis
var a = Math.Atan2(v.X, v.Z);
@Vercidium
Vercidium / generateAxis.cs
Last active May 4, 2019 01:21
Generating Galaxy Axis from Stars
var v = GetPoint();
// Add some variance to each star
v += NextV3(-0.5, 0.5);
// Shift stars vertically as they get closer to the center of the galaxy
var s = beamHeight / v.Magnitude;
v.Y = Next(-s, s);
@Vercidium
Vercidium / generateArms.cs
Last active May 4, 2019 02:36
Part 1 - Generating Galaxy Axis and Arms
Vector3 GetPoint()
{
Vector3 v;
double armDivisor = Math.PI / armCount;
while (true)
{
// Generate a random normalised point with a weighting
// towards the center controlled by the gravity variable
v = NextV3(-1, 1).Normalized() * Math.Pow(Next(0, 1.0), gravity);