///
/// MIT License - Copyright(c) 2019 Ugo Belfiore
///
using UnityEngine;
namespace PerspectiveSwitcher
{
public static class ExtMatrix
{
///
/// apply a lerp between the 2 matrix by time
///
/// Lerped matrix
public static Matrix4x4 MatrixLerp(Matrix4x4 from, Matrix4x4 to, float time)
{
Matrix4x4 ret = new Matrix4x4();
for (int i = 0; i < 16; i++)
ret[i] = Mathf.Lerp(from[i], to[i], time);
return ret;
}
///
/// get an Orthographic matrix
///
/// aspect ratio
/// size of the orthigraphic projection
/// near
/// far
/// Orthographic matrix
public static Matrix4x4 GetMatrixOrthographic(float aspect, float orthographicSize, float nearClippingPlane, float farClippingPlane)
{
return (Matrix4x4.Ortho(-orthographicSize * aspect, orthographicSize * aspect, -orthographicSize, orthographicSize, nearClippingPlane, farClippingPlane));
}
///
/// get an Perspective matrix
///
/// aspect ratio
/// field Of View of the camera
/// near
/// far
/// Perspective matrix
public static Matrix4x4 GetMatrixPerspective(float aspect, float fieldOfView, float nearClippingPlane, float farClippingPlane)
{
return (Matrix4x4.Perspective(fieldOfView, aspect, nearClippingPlane, farClippingPlane));
}
}
}