feat: integer vector 2d & 3d added

This commit is contained in:
2025-10-16 14:12:24 +03:00
parent 69bc6573d1
commit 92a5c276a4
2 changed files with 618 additions and 0 deletions

View File

@@ -0,0 +1,305 @@
using System;
namespace Engine.Core;
/// <summary>
/// Represents a two-dimensional integer vector.
/// </summary>
/// <param name="x">X position of the <see cref="Vector2DInt"/>.</param>
/// <param name="y">Y position of the <see cref="Vector2DInt"/>.</param>
/// <remarks>
/// Initializes a new instance of the <see cref="Vector2DInt"/> struct with the specified positions.
/// </remarks>
[System.Diagnostics.DebuggerDisplay("{ToString(),nq}")]
public readonly struct Vector2DInt(int x, int y) : IEquatable<Vector2DInt>
{
/// <summary>
/// The X coordinate of the <see cref="Vector2DInt"/>.
/// </summary>
public readonly int X = x;
/// <summary>
/// The Y coordinate of the <see cref="Vector2DInt"/>.
/// </summary>
public readonly int Y = y;
/// <summary>
/// The magnitude (length) of the <see cref="Vector2DInt"/>.
/// </summary>
public float Magnitude => Length(this);
/// <summary>
/// The squared magnitude (length) of the <see cref="Vector2DInt"/>.
/// </summary>
public float MagnitudeSquared => LengthSquared(this);
/// <summary>
/// Gets a <see cref="Vector2DInt"/> with the direction reversed.
/// </summary>
public readonly Vector2DInt Reversed => -this;
/// <summary>
/// Represents the unit <see cref="Vector2DInt"/> pointing upwards.
/// </summary>
public readonly static Vector2DInt Up = new(0, 1);
/// <summary>
/// Represents the unit <see cref="Vector2DInt"/> pointing downwards.
/// </summary>
public readonly static Vector2DInt Down = new(0, -1);
/// <summary>
/// Represents the unit <see cref="Vector2DInt"/> pointing leftwards.
/// </summary>
public readonly static Vector2DInt Left = new(-1, 0);
/// <summary>
/// Represents the unit <see cref="Vector2DInt"/> pointing rightwards.
/// </summary>
public readonly static Vector2DInt Right = new(1, 0);
/// <summary>
/// Represents the zero <see cref="Vector2DInt"/>.
/// </summary>
public readonly static Vector2DInt Zero = new(0, 0);
/// <summary>
/// Represents the <see cref="Vector2DInt"/> with both components equal to 1.
/// </summary>
public readonly static Vector2DInt One = new(1, 1);
public static Vector2DInt operator -(Vector2DInt vector) => new(0 - vector.X, 0 - vector.Y);
public static Vector2DInt operator +(Vector2DInt left, Vector2DInt right) => new(left.X + right.X, left.Y + right.Y);
public static Vector2DInt operator -(Vector2DInt left, Vector2DInt right) => new(left.X - right.X, left.Y - right.Y);
public static Vector2DInt operator *(Vector2DInt vector, int value) => new(vector.X * value, vector.Y * value);
public static Vector2DInt operator *(int value, Vector2DInt vector) => new(vector.X * value, vector.Y * value);
public static Vector2DInt operator /(Vector2DInt vector, int value) => new(vector.X / value, vector.Y / value);
public static bool operator ==(Vector2DInt left, Vector2DInt right) => left.X == right.X && left.Y == right.Y;
public static bool operator !=(Vector2DInt left, Vector2DInt right) => left.X != right.X || left.Y != right.Y;
public static implicit operator Vector2DInt(Vector3DInt vector) => new(vector.X, vector.Y);
/// <summary>
/// Calculates the length of the <see cref="Vector2DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <returns>The length of the <see cref="Vector2DInt"/>.</returns>
public static float Length(Vector2DInt vector) => Engine.Core.Math.Sqrt(LengthSquared(vector));
/// <summary>
/// Calculates the squared length of the <see cref="Vector2DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <returns>The squared length of the <see cref="Vector2DInt"/>.</returns>
public static float LengthSquared(Vector2DInt vector) => vector.X * vector.X + vector.Y * vector.Y;
/// <summary>
/// Calculates the distance between two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="from">The start <see cref="Vector2DInt"/>.</param>
/// <param name="to">The end <see cref="Vector2DInt"/>.</param>
/// <returns>The distance between the two <see cref="Vector2DInt"/>s.</returns>
public static float Distance(Vector2DInt from, Vector2DInt to) => Length(FromTo(from, to));
/// <summary>
/// Inverts the direction of the <see cref="Vector2DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <returns>The inverted <see cref="Vector2DInt"/>.</returns>
public static Vector2DInt Invert(Vector2DInt vector) => -vector;
/// <summary>
/// Adds two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector2DInt"/>.</param>
/// <param name="right">The second <see cref="Vector2DInt"/>.</param>
/// <returns>The sum of the two <see cref="Vector2DInt"/>s.</returns>
public static Vector2DInt Add(Vector2DInt left, Vector2DInt right) => left + right;
/// <summary>
/// Subtracts one <see cref="Vector2DInt"/> from another.
/// </summary>
/// <param name="left">The <see cref="Vector2DInt"/> to subtract from.</param>
/// <param name="right">The <see cref="Vector2DInt"/> to subtract.</param>
/// <returns>The result of subtracting the second <see cref="Vector2DInt"/> from the first.</returns>
public static Vector2DInt Subtract(Vector2DInt left, Vector2DInt right) => left - right;
/// <summary>
/// Multiplies a <see cref="Vector2DInt"/> by a scalar value.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <param name="value">The scalar value.</param>
/// <returns>The result of multiplying the <see cref="Vector2DInt"/> by the scalar value.</returns>
public static Vector2DInt Multiply(Vector2DInt vector, int value) => vector * value;
/// <summary>
/// Divides a <see cref="Vector2DInt"/> by a scalar value.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <param name="value">The scalar value.</param>
/// <returns>The result of dividing the <see cref="Vector2DInt"/> by the scalar value.</returns>
public static Vector2DInt Divide(Vector2DInt vector, int value) => vector / value;
/// <summary>
/// Calculates the absolute value of each component of the vector.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/>.</param>
/// <returns>The <see cref="Vector2DInt"/> with each component's absolute value.</returns>
public static Vector2DInt Abs(Vector2DInt vector) => new(Engine.Core.Math.Abs(vector.X), Engine.Core.Math.Abs(vector.Y));
/// <summary>
/// Calculates the <see cref="Vector2DInt"/> from one point to another.
/// </summary>
/// <param name="from">The starting point.</param>
/// <param name="to">The ending point.</param>
/// <returns>The <see cref="Vector2DInt"/> from the starting point to the ending point.</returns>
public static Vector2DInt FromTo(Vector2DInt from, Vector2DInt to) => to - from;
/// <summary>
/// Scales a <see cref="Vector2DInt"/> by another <see cref="Vector2DInt"/> component-wise.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/> to scale.</param>
/// <param name="scale">The <see cref="Vector2DInt"/> containing the scaling factors for each component.</param>
/// <returns>The scaled <see cref="Vector2DInt"/>.</returns>
public static Vector2DInt Scale(Vector2DInt vector, Vector2DInt scale) => new(vector.X * scale.X, vector.Y * scale.Y);
/// <summary>
/// Calculates a perpendicular <see cref="Vector2DInt"/> to the given <see cref="Vector2DInt"/>.
/// </summary>
/// <param name="vector">The input <see cref="Vector2DInt"/>.</param>
/// <returns>A <see cref="Vector2DInt"/> perpendicular to the input <see cref="Vector2DInt"/>.</returns>
public static Vector2DInt Perpendicular(Vector2DInt vector) => new(-vector.Y, vector.X);
/// <summary>
/// Returns the component-wise minimum of two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector2DInt"/>.</param>
/// <param name="right">The second <see cref="Vector2DInt"/>.</param>
/// <returns>The <see cref="Vector2DInt"/> containing the minimum components from both input <see cref="Vector2DInt"/>s.</returns>
public static Vector2DInt Min(Vector2DInt left, Vector2DInt right) => new((left.X < right.X) ? left.X : right.X, (left.Y < right.Y) ? left.Y : right.Y);
/// <summary>
/// Returns the component-wise maximum of two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector2DInt"/>.</param>
/// <param name="right">The second <see cref="Vector2DInt"/>.</param>
/// <returns>The <see cref="Vector2DInt"/> containing the maximum components from both input <see cref="Vector2DInt"/>s.</returns>
public static Vector2DInt Max(Vector2DInt left, Vector2DInt right) => new((left.X > right.X) ? left.X : right.X, (left.Y > right.Y) ? left.Y : right.Y);
/// <summary>
/// Clamps each component of a <see cref="Vector2DInt"/> between the corresponding component of two other <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="vector">The <see cref="Vector2DInt"/> to clamp.</param>
/// <param name="min">The <see cref="Vector2DInt"/> representing the minimum values for each component.</param>
/// <param name="max">The <see cref="Vector2DInt"/> representing the maximum values for each component.</param>
/// <returns>A <see cref="Vector2DInt"/> with each component clamped between the corresponding components of the min and max <see cref="Vector2DInt"/>s.</returns>
public static Vector2DInt Clamp(Vector2DInt vector, Vector2DInt min, Vector2DInt max) => new(Engine.Core.Math.Clamp(vector.X, min.X, max.X), Engine.Core.Math.Clamp(vector.Y, min.Y, max.Y));
/// <summary>
/// Performs linear interpolation between two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="from">The starting <see cref="Vector2DInt"/> (t = 0).</param>
/// <param name="to">The ending <see cref="Vector2DInt"/> (t = 1).</param>
/// <param name="t">The interpolation parameter.</param>
/// <returns>The interpolated <see cref="Vector2DInt"/>.</returns>
public static Vector2DInt Lerp(Vector2DInt from, Vector2DInt to, int t) => from + FromTo(from, to) * t;
/// <summary>
/// Calculates the cross product of two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector2DInt"/>.</param>
/// <param name="right">The second <see cref="Vector2DInt"/>.</param>
/// <returns>The cross product of the two <see cref="Vector2DInt"/>s.</returns>
public static int Cross(Vector2DInt left, Vector2DInt right) => left.X * right.Y - left.Y * right.X;
/// <summary>
/// Calculates the dot product of two <see cref="Vector2DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector2DInt"/>.</param>
/// <param name="right">The second <see cref="Vector2DInt"/>.</param>
/// <returns>The dot product of the two <see cref="Vector2DInt"/>s.</returns>
public static int Dot(Vector2DInt left, Vector2DInt right) => left.X * right.X + left.Y * right.Y;
/// <summary>
/// Determines whether the specified object is equal to the current <see cref="Vector2DInt"/>.
/// </summary>
/// <param name="obj">The object to compare with the current <see cref="Vector2DInt"/>.</param>
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector2DInt"/>; otherwise, <see cref="false"/>.</returns>
public override bool Equals(object? obj) => obj is Vector2DInt vector2DInt && this == vector2DInt;
public bool Equals(Vector2DInt other) => this == other;
/// <summary>
/// Generates a hash code for the <see cref="Vector2DInt"/>.
/// </summary>
/// <returns>A hash code for the <see cref="Vector2DInt"/>.</returns>
public override int GetHashCode() => System.HashCode.Combine(X, Y);
/// <summary>
/// Converts the <see cref="Vector2DInt"/> to its string representation.
/// </summary>
/// <returns>A string representation of the <see cref="Vector2DInt"/>.</returns>
public override string ToString() => $"{nameof(Vector2DInt)}({X}, {Y})";
}
/// <summary>
/// Provides extension methods for <see cref="Vector2DInt"/> type.
/// </summary>
public static class Vector2DIntExtensions
{
/// <inheritdoc cref="Vector2DInt.Length(Vector2DInt)" />
public static float Length(this Vector2DInt vector) => Vector2DInt.Length(vector);
/// <inheritdoc cref="Vector2DInt.LengthSquared(this vector) => Vector2DInt/>
public static float LengthSquared(this Vector2DInt vector) => Vector2DInt.LengthSquared(vector);
/// <inheritdoc cref="Vector2DInt.Distance(Vector2DInt, Vector2DInt)" />
public static float Distance(this Vector2DInt from, Vector2DInt to) => Vector2DInt.Distance(from, to);
/// <inheritdoc cref="Vector2DInt.Invert(this vector) => Vector2DInt/>
public static Vector2DInt Invert(this Vector2DInt vector) => Vector2DInt.Invert(vector);
/// <inheritdoc cref="Vector2DInt.Add(Vector2DInt, Vector2DInt)" />
public static Vector2DInt Add(this Vector2DInt vector, Vector2DInt vectorToAdd) => Vector2DInt.Add(vector, vectorToAdd);
/// <inheritdoc cref="Vector2DInt.Subtract(Vector2DInt, Vector2DInt)" />
public static Vector2DInt Subtract(this Vector2DInt vector, Vector2DInt vectorToSubtract) => Vector2DInt.Subtract(vector, vectorToSubtract);
/// <inheritdoc cref="Vector2DInt.Multiply(Vector2DInt, int)" />
public static Vector2DInt Multiply(this Vector2DInt vector, int value) => Vector2DInt.Multiply(vector, value);
/// <inheritdoc cref="Vector2DInt.Divide(Vector2DInt, int)" />
public static Vector2DInt Divide(this Vector2DInt vector, int value) => Vector2DInt.Divide(vector, value);
/// <inheritdoc cref="Vector2DInt.Abs(Vector2DInt)" />
public static Vector2DInt Abs(this Vector2DInt vector) => Vector2DInt.Abs(vector);
/// <inheritdoc cref="Vector2DInt.FromTo(Vector2DInt, Vector2DInt)" />
public static Vector2DInt FromTo(this Vector2DInt from, Vector2DInt to) => Vector2DInt.FromTo(from, to);
/// <inheritdoc cref="Vector2DInt.Scale(Vector2DInt, Vector2DInt)" />
public static Vector2DInt Scale(this Vector2DInt vector, Vector2DInt scale) => Vector2DInt.Scale(vector, scale);
/// <inheritdoc cref="Vector2DInt.Perpendicular(Vector2DInt)" />
public static Vector2DInt Perpendicular(this Vector2DInt vector) => Vector2DInt.Perpendicular(vector);
/// <inheritdoc cref="Vector2DInt.Min(Vector2DInt, Vector2DInt)" />
public static Vector2DInt Min(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Min(left, right);
/// <inheritdoc cref="Vector2DInt.Max(Vector2DInt, Vector2DInt)" />
public static Vector2DInt Max(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Max(left, right);
/// <inheritdoc cref="Vector2DInt.Clamp(Vector2DInt, Vector2DInt,Vector2DInt)" />
public static Vector2DInt Clamp(this Vector2DInt vector, Vector2DInt min, Vector2DInt max) => Vector2DInt.Clamp(vector, min, max);
/// <inheritdoc cref="Vector2DInt.Lerp(Vector2DInt, Vector2DInt," />
public static Vector2DInt Lerp(this Vector2DInt from, Vector2DInt to, int t) => Vector2DInt.Lerp(from, to, t);
/// <inheritdoc cref="Vector2DInt.Cross(Vector2DInt, Vector2DInt)" />
public static int Cross(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Cross(left, right);
/// <inheritdoc cref="Vector2D.Angle(Vector2D, Vector2D)" />
public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right);
/// <inheritdoc cref="Vector2DInt.Dot(Vector2DInt, Vector2DInt)" />
public static int Dot(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Dot(left, right);
}

View File

@@ -0,0 +1,313 @@
using System;
namespace Engine.Core;
/// <summary>
/// Represents a three-dimensional integer vector.
/// </summary>
/// <param name="x">X position of the <see cref="Vector3DInt"/>.</param>
/// <param name="y">Y position of the <see cref="Vector3DInt"/>.</param>
/// <param name="z">Z position of the <see cref="Vector3DInt"/>.</param>
/// <remarks>
/// Initializes a new instance of the <see cref="Vector3DInt"/> struct with the specified positions.
/// </remarks>
[System.Diagnostics.DebuggerDisplay("{ToString(),nq}")]
public readonly struct Vector3DInt(int x, int y, int z) : IEquatable<Vector3DInt>
{
/// <summary>
/// The X coordinate of the <see cref="Vector3DInt"/>.
/// </summary>
public readonly int X = x;
/// <summary>
/// The Y coordinate of the <see cref="Vector3DInt"/>.
/// </summary>
public readonly int Y = y;
/// <summary>
/// The Z coordinate of the <see cref="Vector3DInt"/>.
/// </summary>
public readonly int Z = z;
/// <summary>
/// The magnitude (length) of the <see cref="Vector3DInt"/>.
/// </summary>
public float Magnitude => Length(this);
/// <summary>
/// The squared magnitude (length) of the <see cref="Vector3DInt"/>.
/// </summary>
public float MagnitudeSquared => LengthSquared(this);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing upwards.
/// </summary>
public readonly static Vector3DInt Up = new(0, 1, 0);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing downwards.
/// </summary>
public readonly static Vector3DInt Down = new(0, -1, 0);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing leftwards.
/// </summary>
public readonly static Vector3DInt Left = new(-1, 0, 0);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing rightwards.
/// </summary>
public readonly static Vector3DInt Right = new(1, 0, 0);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing forwards.
/// </summary>
public readonly static Vector3DInt Forward = new(0, 0, 1);
/// <summary>
/// Represents the unit <see cref="Vector3DInt"/> pointing backwards.
public readonly static Vector3DInt Backward = new(0, 0, -1);
/// <summary>
/// Represents the zero <see cref="Vector3DInt"/>.
/// </summary>
public readonly static Vector3DInt Zero = new(0, 0, 0);
/// <summary>
/// Represents the <see cref="Vector3DInt"/> with both components equal to 1.
/// </summary>
public readonly static Vector3DInt One = new(1, 1, 1);
public static Vector3DInt operator -(Vector3DInt vector) => new(0 - vector.X, 0 - vector.Y, 0 - vector.Z);
public static Vector3DInt operator +(Vector3DInt left, Vector3DInt right) => new(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
public static Vector3DInt operator -(Vector3DInt left, Vector3DInt right) => new(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
public static Vector3DInt operator *(Vector3DInt vector, int value) => new(vector.X * value, vector.Y * value, vector.Z * value);
public static Vector3DInt operator *(int value, Vector3DInt vector) => new(vector.X * value, vector.Y * value, vector.Z * value);
public static Vector3DInt operator /(Vector3DInt vector, int value) => new(vector.X / value, vector.Y / value, vector.Z / value);
public static bool operator ==(Vector3DInt left, Vector3DInt right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z;
public static bool operator !=(Vector3DInt left, Vector3DInt right) => left.X != right.X || left.Y != right.Y || left.Z != right.Z;
public static implicit operator Vector3DInt(Vector2DInt vector) => new(vector.X, vector.Y, 0);
/// <summary>
/// Calculates the length of the <see cref="Vector3DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <returns>The length of the <see cref="Vector3DInt"/>.</returns>
public static float Length(Vector3DInt vector) => Math.Sqrt(LengthSquared(vector));
/// <summary>
/// Calculates the squared length of the <see cref="Vector3DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <returns>The squared length of the <see cref="Vector3DInt"/>.</returns>
public static float LengthSquared(Vector3DInt vector) => vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z;
/// <summary>
/// Calculates the distance between two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="from">The start <see cref="Vector3DInt"/>.</param>
/// <param name="to">The end <see cref="Vector3DInt"/>.</param>
/// <returns>The distance between the two <see cref="Vector3DInt"/>s.</returns>
public static float Distance(Vector3DInt from, Vector3DInt to) => Length(FromTo(from, to));
/// <summary>
/// Inverts the direction of the <see cref="Vector3DInt"/>.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <returns>The inverted <see cref="Vector3DInt"/>.</returns>
public static Vector3DInt Invert(Vector3DInt vector) => -vector;
/// <summary>
/// Adds two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The sum of the two <see cref="Vector3DInt"/>s.</returns>
public static Vector3DInt Add(Vector3DInt left, Vector3DInt right) => left + right;
/// <summary>
/// Subtracts one <see cref="Vector3DInt"/> from another.
/// </summary>
/// <param name="left">The <see cref="Vector3DInt"/> to subtract from.</param>
/// <param name="right">The <see cref="Vector3DInt"/> to subtract.</param>
/// <returns>The result of subtracting the second <see cref="Vector3DInt"/> from the first.</returns>
public static Vector3DInt Subtract(Vector3DInt left, Vector3DInt right) => left - right;
/// <summary>
/// Multiplies a <see cref="Vector3DInt"/> by a scalar value.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <param name="value">The scalar value.</param>
/// <returns>The result of multiplying the <see cref="Vector3DInt"/> by the scalar value.</returns>
public static Vector3DInt Multiply(Vector3DInt vector, int value) => vector * value;
/// <summary>
/// Divides a <see cref="Vector3DInt"/> by a scalar value.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <param name="value">The scalar value.</param>
/// <returns>The result of dividing the <see cref="Vector3DInt"/> by the scalar value.</returns>
public static Vector3DInt Divide(Vector3DInt vector, int value) => vector / value;
/// <summary>
/// Calculates the absolute value of each component of the vector.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/>.</param>
/// <returns>The <see cref="Vector3DInt"/> with each component's absolute value.</returns>
public static Vector3DInt Abs(Vector3DInt vector) => new(Math.Abs(vector.X), Math.Abs(vector.Y), Math.Abs(vector.Z));
/// <summary>
/// Calculates the <see cref="Vector3DInt"/> from one point to another.
/// </summary>
/// <param name="from">The starting point.</param>
/// <param name="to">The ending point.</param>
/// <returns>The <see cref="Vector3DInt"/> from the starting point to the ending point.</returns>
public static Vector3DInt FromTo(Vector3DInt from, Vector3DInt to) => to - from;
/// <summary>
/// Scales a <see cref="Vector3DInt"/> by another <see cref="Vector3DInt"/> component-wise.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/> to scale.</param>
/// <param name="scale">The <see cref="Vector3DInt"/> containing the scaling factors for each component.</param>
/// <returns>The scaled <see cref="Vector3DInt"/>.</returns>
public static Vector3DInt Scale(Vector3DInt vector, Vector3DInt scale) => new(vector.X * scale.X, vector.Y * scale.Y, vector.Z * scale.Z);
/// <summary>
/// Returns the component-wise minimum of two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The <see cref="Vector3DInt"/> containing the minimum components from both input <see cref="Vector3DInt"/>s.</returns>
public static Vector3DInt Min(Vector3DInt left, Vector3DInt right) => new((left.X < right.X) ? left.X : right.X, (left.Y < right.Y) ? left.Y : right.Y, (left.Z < right.Z) ? left.Z : right.Z);
/// <summary>
/// Returns the component-wise maximum of two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The <see cref="Vector3DInt"/> containing the maximum components from both input <see cref="Vector3DInt"/>s.</returns>
public static Vector3DInt Max(Vector3DInt left, Vector3DInt right) => new((left.X > right.X) ? left.X : right.X, (left.Y > right.Y) ? left.Y : right.Y, (left.Z > right.Z) ? left.Z : right.Z);
/// <summary>
/// Clamps each component of a <see cref="Vector3DInt"/> between the corresponding component of two other <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="vector">The <see cref="Vector3DInt"/> to clamp.</param>
/// <param name="min">The <see cref="Vector3DInt"/> representing the minimum values for each component.</param>
/// <param name="max">The <see cref="Vector3DInt"/> representing the maximum values for each component.</param>
/// <returns>A <see cref="Vector3DInt"/> with each component clamped between the corresponding components of the min and max <see cref="Vector3DInt"/>s.</returns>
public static Vector3DInt Clamp(Vector3DInt vector, Vector3DInt min, Vector3DInt max) => new(Math.Clamp(vector.X, min.X, max.X), Math.Clamp(vector.Y, min.Y, max.Y), Math.Clamp(vector.Z, min.Z, max.Z));
/// <summary>
/// Performs linear interpolation between two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="from">The starting <see cref="Vector3DInt"/> (t = 0).</param>
/// <param name="to">The ending <see cref="Vector3DInt"/> (t = 1).</param>
/// <param name="t">The interpolation parameter.</param>
/// <returns>The interpolated <see cref="Vector3DInt"/>.</returns>
public static Vector3DInt Lerp(Vector3DInt from, Vector3DInt to, int t) => from + FromTo(from, to) * t;
/// <summary>
/// Calculates the cross product of two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The cross product of the two <see cref="Vector3DInt"/>s.</returns>
public static Vector3DInt Cross(Vector3DInt left, Vector3DInt right) => new(left.Y * right.Z - left.Z * right.Y, left.Z * right.X - left.X * right.Z, left.X * right.Y - left.Y * right.X);
/// <summary>
/// Calculates the angle between two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The angle between the two <see cref="Vector3DInt"/>s in radians.</returns>
public static float Angle(Vector3DInt left, Vector3DInt right) => Math.Acos(Dot(left, right) / (Length(left) * Length(right)));
/// <summary>
/// Calculates the dot product of two <see cref="Vector3DInt"/>s.
/// </summary>
/// <param name="left">The first <see cref="Vector3DInt"/>.</param>
/// <param name="right">The second <see cref="Vector3DInt"/>.</param>
/// <returns>The dot product of the two <see cref="Vector3DInt"/>s.</returns>
public static int Dot(Vector3DInt left, Vector3DInt right) => left.X * right.X + left.Y * right.Y + left.Z * right.Z;
/// <summary>
/// Determines whether the specified object is equal to the current <see cref="Vector3DInt"/>.
/// </summary>
/// <param name="obj">The object to compare with the current <see cref="Vector3DInt"/>.</param>
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector3DInt"/>; otherwise, <see cref="false"/>.</returns>
public override bool Equals(object? obj) => obj is Vector3DInt vector3D && this == vector3D;
public bool Equals(Vector3DInt other) => this == other;
/// <summary>
/// Generates a hash code for the <see cref="Vector3DInt"/>.
/// </summary>
/// <returns>A hash code for the <see cref="Vector3DInt"/>.</returns>
public override int GetHashCode() => System.HashCode.Combine(X, Y, Z);
/// <summary>
/// Converts the <see cref="Vector3DInt"/> to its string representation.
/// </summary>
/// <returns>A string representation of the <see cref="Vector3DInt"/>.</returns>
public override string ToString() => $"{nameof(Vector3DInt)}({X}, {Y}, {Z})";
}
/// <summary>
/// Provides extension methods for <see cref="Vector3DInt"/> type.
/// </summary>
public static class Vector3DIntExtensions
{
/// <inheritdoc cref="Vector3DInt.Length(Vector3DInt)" />
public static float Length(this Vector3DInt vector) => Vector3DInt.Length(vector);
/// <inheritdoc cref="Vector3DInt.LengthSquared(Vector3DInt)" />
public static float LengthSquared(this Vector3DInt vector) => Vector3DInt.LengthSquared(vector);
/// <inheritdoc cref="Vector3DInt.Distance(Vector3DInt, Vector3DInt)" />
public static float Distance(this Vector3DInt from, Vector3DInt to) => Vector3DInt.Distance(from, to);
/// <inheritdoc cref="Vector3DInt.Invert(Vector3DInt)" />
public static Vector3DInt Invert(this Vector3DInt vector) => Vector3DInt.Invert(vector);
/// <inheritdoc cref="Vector3DInt.Add(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Add(this Vector3DInt vector, Vector3DInt vectorToAdd) => Vector3DInt.Add(vector, vectorToAdd);
/// <inheritdoc cref="Vector3DInt.Subtract(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Subtract(this Vector3DInt vector, Vector3DInt vectorToSubtract) => Vector3DInt.Subtract(vector, vectorToSubtract);
/// <inheritdoc cref="Vector3DInt.Multiply(Vector3DInt, int)" />
public static Vector3DInt Multiply(this Vector3DInt vector, int value) => Vector3DInt.Multiply(vector, value);
/// <inheritdoc cref="Vector3DInt.Divide(Vector3DInt, int)" />
public static Vector3DInt Divide(this Vector3DInt vector, int value) => Vector3DInt.Divide(vector, value);
/// <inheritdoc cref="Vector3DInt.Abs(Vector3DInt)" />
public static Vector3DInt Abs(this Vector3DInt vector) => Vector3DInt.Abs(vector);
/// <inheritdoc cref="Vector3DInt.FromTo(Vector3DInt, Vector3DInt)" />
public static Vector3DInt FromTo(this Vector3DInt from, Vector3DInt to) => Vector3DInt.FromTo(from, to);
/// <inheritdoc cref="Vector3DInt.Scale(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Scale(this Vector3DInt vector, Vector3DInt scale) => Vector3DInt.Scale(vector, scale);
/// <inheritdoc cref="Vector3DInt.Min(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Min(this Vector3DInt left, Vector3DInt right) => Vector3DInt.Min(left, right);
/// <inheritdoc cref="Vector3DInt.Max(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Max(this Vector3DInt left, Vector3DInt right) => Vector3DInt.Max(left, right);
/// <inheritdoc cref="Vector3DInt.Clamp(Vector3DInt, Vector3DInt, Vector3DInt)" />
public static Vector3DInt Clamp(this Vector3DInt vector, Vector3DInt min, Vector3DInt max) => Vector3DInt.Clamp(vector, min, max);
/// <inheritdoc cref="Vector3DInt.Lerp(Vector3DInt, Vector3DInt, int)" />
public static Vector3DInt Lerp(this Vector3DInt from, Vector3DInt to, int t) => Vector3DInt.Lerp(from, to, t);
/// <inheritdoc cref="Vector3DInt.Cross(Vector3DInt, Vector3DInt)" />
public static Vector3DInt Cross(this Vector3DInt left, Vector3DInt right) => Vector3DInt.Cross(left, right);
/// <inheritdoc cref="Vector3DInt.Angle(Vector3DInt, Vector3DInt)" />
public static float AngleBetween(this Vector3DInt left, Vector3DInt right) => Vector3DInt.Angle(left, right);
/// <inheritdoc cref="Vector3DInt.Dot(Vector3DInt, Vector3DInt)" />
public static int Dot(this Vector3DInt left, Vector3DInt right) => Vector3DInt.Dot(left, right);
}