Table of Contents

Class RectangularDirectionUtility

Namespace
GridForge.Spatial
Assembly
GridForge.dll

Provides rectangular-prism neighbor direction utilities.

public static class RectangularDirectionUtility
Inheritance
RectangularDirectionUtility
Inherited Members

Properties

AboveLayer

All 9 neighbor directions on the layer above.

public static ReadOnlySpan<RectangularDirection> AboveLayer { get; }

Property Value

ReadOnlySpan<RectangularDirection>

All

All 26 neighbor directions excluding None.

public static ReadOnlySpan<RectangularDirection> All { get; }

Property Value

ReadOnlySpan<RectangularDirection>

BelowLayer

All 9 neighbor directions on the layer below.

public static ReadOnlySpan<RectangularDirection> BelowLayer { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Diagonal

All 20 diagonal neighbor directions excluding None.

public static ReadOnlySpan<RectangularDirection> Diagonal { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Offsets

Predefined offsets for a rectangular-prism 3x3x3 neighbor structure, excluding the center position.

public static ReadOnlySpan<(int x, int y, int z)> Offsets { get; }

Property Value

ReadOnlySpan<(int x, int y, int z)>

Perpendicular

All 6 perpendicular neighbor directions excluding None.

public static ReadOnlySpan<RectangularDirection> Perpendicular { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Planar

All 8 same-layer XZ-plane directions excluding None.

public static ReadOnlySpan<RectangularDirection> Planar { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Primary

The 6 face-adjacent rectangular-prism directions.

public static ReadOnlySpan<RectangularDirection> Primary { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Vertical

All 2 vertical directions.

public static ReadOnlySpan<RectangularDirection> Vertical { get; }

Property Value

ReadOnlySpan<RectangularDirection>

VerticalDiagonal

All 16 non-vertical directions on the layers above and below.

public static ReadOnlySpan<RectangularDirection> VerticalDiagonal { get; }

Property Value

ReadOnlySpan<RectangularDirection>

Methods

GetBoundaryRange(int, int)

Gets the boundary range for a given offset and size, returning (0, 0) for negative offsets, (size-1, size-1) for positive offsets, and (0, size-1) for zero offsets.

public static (int start, int end) GetBoundaryRange(int offset, int size)

Parameters

offset int

The offset value.

size int

The size of the dimension.

Returns

(int start, int end)

A tuple representing the start and end of the boundary range.

GetDirectionFromOffset((int x, int y, int z))

Converts a rectangular local offset in the range [-1, 1] on each axis into a direction.

public static RectangularDirection GetDirectionFromOffset((int x, int y, int z) offset)

Parameters

offset (int x, int y, int z)

Returns

RectangularDirection

IsAxisFacingBoundary(int, int, int)

Determines if a coordinate is facing the boundary of an axis given an offset and size.

public static bool IsAxisFacingBoundary(int coordinate, int offset, int size)

Parameters

coordinate int

The coordinate value.

offset int

The offset value.

size int

The size of the dimension.

Returns

bool

True if the coordinate is facing the boundary, otherwise false.

IsDiagonalNeighbor(RectangularDirection)

True for any diagonal step (multiple axes).

public static bool IsDiagonalNeighbor(RectangularDirection dir)

Parameters

dir RectangularDirection

Returns

bool

IsPerpendicularNeighbor(RectangularDirection)

True for pure axis-aligned directions.

public static bool IsPerpendicularNeighbor(RectangularDirection dir)

Parameters

dir RectangularDirection

Returns

bool