import torch


def construct_K(fx, fy, cx, cy, dtype=torch.float, device=None):
    """Create camera intrinsics from focal length and focal center

    Parameters
    ----------
    fx: float
        Camera focal length along x-axis.
    fy: float
        Camera focal length along y-axis.
    cx: float
        Camera x-axis principal point.
    cy: float
        Camera y-axis principal point.
    dtype: str
        Tensor dtype
    device: str
        Tensor device

    Returns
    -------
    torch.FloatTensor
        Camera intrinsic matrix (33)
    """
    return torch.tensor([[fx, 0, cx], [0, fy, cy], [0, 0, 1]], dtype=dtype, device=device)