public static MatrixNd createPerspective(int size, double fov, double aspect, double near, double far) {
    """
	Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes
	
	@param size The size of the matrix, minimum of 4
	@param fov The field of view in the x direction
	@param aspect The aspect ratio, usually width/height
	@param near The near plane, cannot be 0
	@param far the far plane, zFar cannot equal zNear
	@return A perspective projection matrix built from the given values
    """
        if (size < 4) {
            throw new IllegalArgumentException("Minimum matrix size is 4");
        }
        final MatrixNd perspective = new MatrixNd(size);
        final double scale = 1 / TrigMath.tan(fov * (double) TrigMath.HALF_DEG_TO_RAD);
        perspective.set(0, 0, scale / aspect);
        perspective.set(1, 1, scale);
        perspective.set(2, 2, (far + near) / (near - far));
        perspective.set(2, 3, 2 * far * near / (near - far));
        perspective.set(3, 2, -1);
        perspective.set(3, 3, 0);
        return perspective;
    }
public static MatrixNd createPerspective(int size, double fov, double aspect, double near, double far) {
        if (size < 4) {
            throw new IllegalArgumentException("Minimum matrix size is 4");
        }
        final MatrixNd perspective = new MatrixNd(size);
        final double scale = 1 / TrigMath.tan(fov * (double) TrigMath.HALF_DEG_TO_RAD);
        perspective.set(0, 0, scale / aspect);
        perspective.set(1, 1, scale);
        perspective.set(2, 2, (far + near) / (near - far));
        perspective.set(2, 3, 2 * far * near / (near - far));
        perspective.set(3, 2, -1);
        perspective.set(3, 3, 0);
        return perspective;
    }
public static MatrixNd createPerspective ( int size , double fov , double aspect , double near , double far ) { if ( size < 4 ) { throw new IllegalArgumentException ( "Minimum matrix size is 4" ) ; } final MatrixNd perspective = new MatrixNd ( size ) ; final double scale = 1 / TrigMath . tan ( fov * ( double ) TrigMath . HALF_DEG_TO_RAD ) ; perspective . set ( 0 , 0 , scale / aspect ) ; perspective . set ( 1 , 1 , scale ) ; perspective . set ( 2 , 2 , ( far + near ) / ( near - far ) ) ; perspective . set ( 2 , 3 , 2 * far * near / ( near - far ) ) ; perspective . set ( 3 , 2 , - 1 ) ; perspective . set ( 3 , 3 , 0 ) ; return perspective ; }
Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes

@param size The size of the matrix, minimum of 4
@param fov The field of view in the x direction
@param aspect The aspect ratio, usually width/height
@param near The near plane, cannot be 0
@param far the far plane, zFar cannot equal zNear
@return A perspective projection matrix built from the given values
Creates a perspective projection matrix with the given ( x ) FOV aspect near and far planes