Table of Contents

Class MarchingSquares

Namespace
Alis.Core.Physic.Common.TextureTools
Assembly
Alis.dll

The marching squares class

public static class MarchingSquares

Inheritance

Inherited Members

Fields

_lookMarch

The look march

private static readonly int[] _lookMarch

Field Value

int[]

Methods

DetectSquares(AABB, float, float, sbyte[,], int, bool)

Marching squares over the given domain using the mesh defined via the dimensions (wid,hei) to build a set of polygons such that f(x,y) less than 0, using the given number 'bin' for recursive linear inteprolation along cell boundaries. if 'comb' is true, then the polygons will also be composited into larger possible concave polygons.

public static List<Vertices> DetectSquares(AABB domain, float cellWidth, float cellHeight, sbyte[,] f, int lerpCount, bool combine)

Parameters

domain AABB
cellWidth float
cellHeight float
f sbyte[,]
lerpCount int
combine bool

Returns

List<Vertices>

Lerp(float, float, float, float)

Lerps the x 0

private static float Lerp(float x0, float x1, float v0, float v1)

Parameters

x0 float

The

x1 float

The

v0 float

The

v1 float

The

Returns

float

The float

MarchSquare(sbyte[,], sbyte[,], ref GeomPoly, int, int, float, float, float, float, int)

Marches the square using the specified f

private static int MarchSquare(sbyte[,] f, sbyte[,] fs, ref MarchingSquares.GeomPoly poly, int ax, int ay, float x0, float y0, float x1, float y1, int bin)

Parameters

f sbyte[,]

The

fs sbyte[,]

The fs

poly MarchingSquares.GeomPoly

The poly

ax int

The ax

ay int

The ay

x0 float

The

y0 float

The

x1 float

The

y1 float

The

bin int

The bin

Returns

int

The key

Square(float)

private static float Square(float x)

Parameters

x float

Returns

float

VecCross(Vector2, Vector2)

Vecs the cross using the specified a

private static float VecCross(Vector2 a, Vector2 b)

Parameters

a Vector2

The

b Vector2

The

Returns

float

The float

VecDsq(Vector2, Vector2)

Vecs the dsq using the specified a

private static float VecDsq(Vector2 a, Vector2 b)

Parameters

a Vector2

The

b Vector2

The

Returns

float

The float

Xlerp(float, float, float, float, float, sbyte[,], int)

private static float Xlerp(float x0, float x1, float y, float v0, float v1, sbyte[,] f, int c)

Parameters

x0 float
x1 float
y float
v0 float
v1 float
f sbyte[,]
c int

Returns

float

Ylerp(float, float, float, float, float, sbyte[,], int)

private static float Ylerp(float y0, float y1, float x, float v0, float v1, sbyte[,] f, int c)

Parameters

y0 float
y1 float
x float
v0 float
v1 float
f sbyte[,]
c int

Returns

float

combLeft(ref GeomPoly, ref GeomPoly)

Combs the left using the specified polya

private static void combLeft(ref MarchingSquares.GeomPoly polya, ref MarchingSquares.GeomPoly polyb)

Parameters

polya MarchingSquares.GeomPoly

The polya

polyb MarchingSquares.GeomPoly

The polyb