Ultimate Sector Generation X Pro Max Silver Edition
Added entrances, exits and factions to sector generation Associated each corporation with a unique name database and color scheme
This commit is contained in:
parent
0f33e541c0
commit
f10804ac11
60 changed files with 1392 additions and 135031 deletions
|
|
@ -67,4 +67,49 @@ public static class AetheriaMath
|
|||
else //determinant = 0; one intercept path, pretty much never happens
|
||||
return max(-b/(2f*a), 0f); //don't shoot back in time
|
||||
}
|
||||
|
||||
// http://csharphelper.com/blog/2016/09/find-the-shortest-distance-between-a-point-and-a-line-segment-in-c/
|
||||
// Calculate the distance between
|
||||
// point pt and the segment p1 --> p2.
|
||||
public static float FindDistanceToSegment(
|
||||
float2 pt, float2 p1, float2 p2, out float2 closest)
|
||||
{
|
||||
float dx = p2.x - p1.x;
|
||||
float dy = p2.y - p1.y;
|
||||
if (dx == 0 && dy == 0)
|
||||
{
|
||||
// It's a point not a line segment.
|
||||
closest = p1;
|
||||
dx = pt.x - p1.x;
|
||||
dy = pt.y - p1.y;
|
||||
return sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
// Calculate the t that minimizes the distance.
|
||||
float t = ((pt.x - p1.x) * dx + (pt.y - p1.y) * dy) /
|
||||
(dx * dx + dy * dy);
|
||||
|
||||
// See if this represents one of the segment's
|
||||
// end points or a point in the middle.
|
||||
if (t < 0)
|
||||
{
|
||||
closest = float2(p1.x, p1.y);
|
||||
dx = pt.x - p1.x;
|
||||
dy = pt.y - p1.y;
|
||||
}
|
||||
else if (t > 1)
|
||||
{
|
||||
closest = float2(p2.x, p2.y);
|
||||
dx = pt.x - p2.x;
|
||||
dy = pt.y - p2.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
closest = float2(p1.x + t * dx, p1.y + t * dy);
|
||||
dx = pt.x - closest.x;
|
||||
dy = pt.y - closest.y;
|
||||
}
|
||||
|
||||
return sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue