General/Vector3Extensions.cs
using ExtendedBox.General;
using ExtendedBox.Maths;
using Sandbox;
using System;

namespace ExtendedBox.General;
public static class Vector3Extensions
{
    public static Vector3 ProjectOnPlane(this Vector3 vector, Vector3 planeNormal) => Vector3.VectorPlaneProject(vector, planeNormal);


    public static Vector3Int FloorToInt(this Vector3 vector) =>
        new(vector.x.FloorToInt(), vector.y.FloorToInt(), vector.z.FloorToInt());

    public static Vector3Int CeilToInt(this Vector3 vector) =>
        new(vector.x.CeilToInt(), vector.y.CeilToInt(), vector.z.CeilToInt());

    public static Vector3Int RoundToInt(this Vector3 vector) =>
        new(vector.x.RoundToInt(), vector.y.RoundToInt(), vector.z.RoundToInt());


    public static (Vector3 min, Vector3 max) ComponentMinMax(this Vector3 vector, Vector3 other) =>
        (vector.ComponentMin(other), vector.ComponentMax(other));

    public static (Vector3Int min, Vector3Int max) ComponentMinMax(this Vector3Int vector, Vector3Int other) =>
        (vector.ComponentMin(other), vector.ComponentMax(other));

    public static Vector3 SnapToGrid(this Vector3Int vector, float gridSize, bool sx = true, bool sy = true, bool sz = true) =>
        ((Vector3)vector).SnapToGrid(gridSize, sx, sy, sz);

    public static bool AlmostEqual(this Vector3Int vector, Vector3 other, float delta = 0.0001f)
    {
        if(Math.Abs(vector.x - other.x) > delta)
            return false;

        if(Math.Abs(vector.y - other.y) > delta)
            return false;

        if(Math.Abs(vector.z - other.z) > delta)
            return false;

        return true;
    }

}