Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Vector/llms.txt

Use this file to discover all available pages before exploring further.

Int3 is a 3-component vector backed by int (32-bit signed integer) values. It is defined in the Prowl.Vector namespace and marked [Serializable]. It is well-suited for voxel chunk coordinates, 3D grid indices, and other discrete spatial tasks.
Int3 does not provide Normalize, Length, Cross, Slerp, or other floating-point geometric methods. Use Float3 or Double3 when those operations are required. Int3 does expose a Dot method that returns an int.

Declaration

[Serializable]
public partial struct Int3 : IEquatable<Int3>, IFormattable

Fields

FieldTypeDescription
XintThe X component.
YintThe Y component.
ZintThe Z component.

Static Constants

PropertyValueDescription
Zero(0, 0, 0)The zero vector.
One(1, 1, 1)A vector with all components set to one.
UnitX(1, 0, 0)The unit vector along the X-axis.
UnitY(0, 1, 0)The unit vector along the Y-axis.
UnitZ(0, 0, 1)The unit vector along the Z-axis.

Constructors

SignatureDescription
Int3(int scalar)Sets all three components to scalar.
Int3(int x, int y, int z)Sets X, Y, and Z individually.
Int3(Int3 v)Copy constructor.
Int3(int[] array)Reads components from an int[] of at least length 3.
Int3(IEnumerable<int> values)Reads components from an enumerable of at least 3 elements.
Int3(ReadOnlySpan<int> span)Reads components from a read-only span of at least length 3.
Int3(Span<int> span)Reads components from a span of at least length 3.
Int3(Int2 xy, int z)Constructs from an Int2 for XY and a separate z.
Int3(int x, Int2 yz)Constructs from a separate x and an Int2 for YZ.
Int3(Float3 v)Truncates a Float3 to integer components (explicit cast).
Int3(Double3 v)Truncates a Double3 to integer components (explicit cast).

Properties

PropertyTypeDescription
this[int index]intGets or sets a component by index. 0X, 1Y, 2Z. Throws IndexOutOfRangeException for any other value.

Operators

Arithmetic — vector × vector (component-wise)

OperatorSignatureDescription
+Int3 + Int3Component-wise addition.
-Int3 - Int3Component-wise subtraction.
*Int3 * Int3Component-wise multiplication.
/Int3 / Int3Component-wise integer division.
%Int3 % Int3Component-wise remainder.

Arithmetic — vector × scalar

OperatorSignatureDescription
+Int3 + int / int + Int3Adds scalar to each component.
-Int3 - int / int - Int3Subtracts scalar from each component (or vice-versa).
*Int3 * int / int * Int3Scales each component.
/Int3 / int / int / Int3Divides each component by scalar (or divides scalar by each component).
%Int3 % int / int % Int3Remainder with scalar.

Bitwise

OperatorSignatureDescription
&Int3 & Int3Component-wise bitwise AND.
|Int3 | Int3Component-wise bitwise OR.
^Int3 ^ Int3Component-wise bitwise XOR.
~~Int3Component-wise bitwise NOT.
<<Int3 << intShifts each component left by the given amount.
>>Int3 >> intShifts each component right by the given amount.

Unary & comparison

OperatorSignatureDescription
Unary --Int3Negates all three components.
==Int3 == Int3Component-wise equality.
!=Int3 != Int3Component-wise inequality.

Casts

ConversionKindDescription
Int2Int3explicitExtends to 3D with Z = 0.
Int3Int2explicitDrops the Z component.
Float3Int3explicitTruncates float components to int.
Double3Int3explicitTruncates double components to int.

Static Methods

SignatureDescription
static int Dot(Int3 x, Int3 y)Returns the integer dot product x.X*y.X + x.Y*y.Y + x.Z*y.Z.

Swizzles

Int3 exposes the full set of GLSL-style swizzle properties for all 2- and 3-component permutations (auto-generated). Read-write swizzles reassign the underlying components; read-only swizzles (where any component repeats) are computed getters. Examples:
Int3 v = new Int3(1, 2, 3);

Int2 xy  = v.XY;   // (1, 2)  — get/set
Int2 zx  = v.ZX;   // (3, 1)  — get/set
Int3 zyx = v.ZYX;  // (3, 2, 1) — get/set
Int3 xxx = v.XXX;  // (1, 1, 1) — get-only

// Write-back
v.YZ = new Int2(10, 20);  // v is now (1, 10, 20)

Instance Methods

SignatureDescription
int[] ToArray()Returns [X, Y, Z] as a new array.
string ToString()Formats as (X, Y, Z) using the current culture.
string ToString(string format)Formats each component with the given numeric format string.
string ToString(string format, IFormatProvider formatProvider)Fully customizable format output.
bool Equals(Int3 other)Component-wise equality.
int GetHashCode()Combined hash of all three components.

Code Example

using Prowl.Vector;

// Voxel chunk coordinate helpers
const int ChunkSize = 16;

Int3 worldVoxel = new Int3(35, 4, -9);

// Convert world voxel → chunk + local voxel
Int3 chunkCoord = worldVoxel / ChunkSize;            // (2, 0, -1)
Int3 localVoxel = worldVoxel - chunkCoord * ChunkSize; // (3, 4, 7)

// Neighbour offsets
Int3[] faceNeighbours = {
    Int3.UnitX, -Int3.UnitX,
    Int3.UnitY, -Int3.UnitY,
    Int3.UnitZ, -Int3.UnitZ,
};

// Bit-pack a small voxel index (0-15 per axis) into a single int
Int3 local = new Int3(3, 5, 7);
Int3 packed = local & new Int3(0xF); // clamp to 4 bits
int  index  = packed.X | (packed.Y << 4) | (packed.Z << 8);

Console.WriteLine($"Chunk coord : {chunkCoord}");
Console.WriteLine($"Local voxel : {localVoxel}");
Console.WriteLine($"Packed index: {index}");

Build docs developers (and LLMs) love