forked from MoonsideGames/MoonTools.Bonk
fix rename gone bad
parent
a46cfcf515
commit
59001ad80a
12
Bonk/AABB.cs
12
Bonk/AABB.cs
|
@ -16,16 +16,16 @@ namespace MoonTools.Core.Bonk
|
||||||
public int Width { get { return MaxX - MinX; } }
|
public int Width { get { return MaxX - MinX; } }
|
||||||
public int Height { get { return MaxY - MinY; } }
|
public int Height { get { return MaxY - MinY; } }
|
||||||
|
|
||||||
public static AABB FromTransform2DedVertices(IEnumerable<Position2D> vertices, Transform2D transform)
|
public static AABB FromTransformedVertices(IEnumerable<Position2D> vertices, Transform2D transform)
|
||||||
{
|
{
|
||||||
var Transform2DedVertices = vertices.Select(vertex => Vector2.Transform(vertex, transform.TransformMatrix));
|
var TransformedVertices = vertices.Select(vertex => Vector2.Transform(vertex, transform.TransformMatrix));
|
||||||
|
|
||||||
return new AABB
|
return new AABB
|
||||||
{
|
{
|
||||||
MinX = (int)Math.Round(Transform2DedVertices.Min(vertex => vertex.X)),
|
MinX = (int)Math.Round(TransformedVertices.Min(vertex => vertex.X)),
|
||||||
MinY = (int)Math.Round(Transform2DedVertices.Min(vertex => vertex.Y)),
|
MinY = (int)Math.Round(TransformedVertices.Min(vertex => vertex.Y)),
|
||||||
MaxX = (int)Math.Round(Transform2DedVertices.Max(vertex => vertex.X)),
|
MaxX = (int)Math.Round(TransformedVertices.Max(vertex => vertex.X)),
|
||||||
MaxY = (int)Math.Round(Transform2DedVertices.Max(vertex => vertex.Y))
|
MaxY = (int)Math.Round(TransformedVertices.Max(vertex => vertex.Y))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
Bonk/Line.cs
12
Bonk/Line.cs
|
@ -15,16 +15,16 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction, Transform2D transform)
|
public Vector2 Support(Vector2 direction, Transform2D transform)
|
||||||
{
|
{
|
||||||
var Transform2DedStart = Vector2.Transform(vertices[0], transform.TransformMatrix);
|
var TransformedStart = Vector2.Transform(vertices[0], transform.TransformMatrix);
|
||||||
var Transform2DedEnd = Vector2.Transform(vertices[1], transform.TransformMatrix);
|
var TransformedEnd = Vector2.Transform(vertices[1], transform.TransformMatrix);
|
||||||
return Vector2.Dot(Transform2DedStart, direction) > Vector2.Dot(Transform2DedEnd, direction) ?
|
return Vector2.Dot(TransformedStart, direction) > Vector2.Dot(TransformedEnd, direction) ?
|
||||||
Transform2DedStart :
|
TransformedStart :
|
||||||
Transform2DedEnd;
|
TransformedEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AABB AABB(Transform2D Transform2D)
|
public AABB AABB(Transform2D Transform2D)
|
||||||
{
|
{
|
||||||
return Bonk.AABB.FromTransform2DedVertices(vertices, Transform2D);
|
return Bonk.AABB.FromTransformedVertices(vertices, Transform2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IShape2D other)
|
public bool Equals(IShape2D other)
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
foreach (var vertex in Vertices)
|
foreach (var vertex in Vertices)
|
||||||
{
|
{
|
||||||
var Transform2DedVertex = Vector2.Transform(vertex, transform.TransformMatrix);
|
var TransformedVertex = Vector2.Transform(vertex, transform.TransformMatrix);
|
||||||
var distance = Vector2.Dot(Transform2DedVertex, direction);
|
var distance = Vector2.Dot(TransformedVertex, direction);
|
||||||
if (distance > furthest)
|
if (distance > furthest)
|
||||||
{
|
{
|
||||||
furthest = distance;
|
furthest = distance;
|
||||||
furthestVertex = Transform2DedVertex;
|
furthestVertex = TransformedVertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public AABB AABB(Transform2D Transform2D)
|
public AABB AABB(Transform2D Transform2D)
|
||||||
{
|
{
|
||||||
return Bonk.AABB.FromTransform2DedVertices(Vertices, Transform2D);
|
return Bonk.AABB.FromTransformedVertices(Vertices, Transform2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IShape2D other)
|
public bool Equals(IShape2D other)
|
||||||
|
|
|
@ -36,12 +36,12 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
foreach (var v in vertices)
|
foreach (var v in vertices)
|
||||||
{
|
{
|
||||||
var Transform2DedVertex = Vector2.Transform(v, transform.TransformMatrix);
|
var TransformedVertex = Vector2.Transform(v, transform.TransformMatrix);
|
||||||
var distance = Vector2.Dot(Transform2DedVertex, direction);
|
var distance = Vector2.Dot(TransformedVertex, direction);
|
||||||
if (distance > furthestDistance)
|
if (distance > furthestDistance)
|
||||||
{
|
{
|
||||||
furthestDistance = distance;
|
furthestDistance = distance;
|
||||||
furthestVertex = Transform2DedVertex;
|
furthestVertex = TransformedVertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public AABB AABB(Transform2D Transform2D)
|
public AABB AABB(Transform2D Transform2D)
|
||||||
{
|
{
|
||||||
return Bonk.AABB.FromTransform2DedVertices(vertices, Transform2D);
|
return Bonk.AABB.FromTransformedVertices(vertices, Transform2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IShape2D other)
|
public bool Equals(IShape2D other)
|
||||||
|
|
Loading…
Reference in New Issue