# Path: p5/pmath/matrix.py
# def _magnitude(arr):
# def _normalize(arry):
# def scale_transform(x, y, z=1):
# def translation_matrix(x, y, z=0):
# def rotation_matrix(axis, angle):
# def euler_rotation_matrix(heading, attitude, bank):
# def triple_axis_rotation_matrix(x, y, z):
# def look_at(eye, at, up):
# def perspective_matrix(field_of_view, aspect_ratio, near_plane, far_plane):
# 
# Path: p5/pmath/utils.py
# PI = math.pi


import unittest
import numpy as np
from p5.pmath import matrix
from p5.pmath.utils import PI

    def test_triple_axis_rotation_matrix(self):
        x = np.array([1, 1, 0])
        y = np.array([0, 1, 0])
        z = np.array([0, 1, 1])

        T = matrix.triple_axis_rotation_matrix(x, y, z)
        R = np.array([
            [1, 1, 0, 0],
            [0, 1, 0, 0],
            [0, 1, 1, 0],
            [0, 0, 0, 1],
        ])
        self.assertTrue(np.array_equal(T, R))

    def test_look_at(self):
        eye = np.array([0, 0, 10])
        at = np.array([0, 0, 0])
        up = np.array([0, 1, 0])

        T = matrix.look_at(eye, at, up)
        R = np.array([
            [1, 0, 0, 0],
            [0, 1, 0, 0],
            [0, 0, 1, -10],
            [0, 0, 0, 1]
        ])
        self.assertTrue(np.array_equal(T, R))

    def test_perspective_matrix(self):

# Path: p5/pmath/matrix.py
# def _magnitude(arr):
# def _normalize(arry):
# def scale_transform(x, y, z=1):
# def translation_matrix(x, y, z=0):
# def rotation_matrix(axis, angle):
# def euler_rotation_matrix(heading, attitude, bank):
# def triple_axis_rotation_matrix(x, y, z):
# def look_at(eye, at, up):
# def perspective_matrix(field_of_view, aspect_ratio, near_plane, far_plane):
# 
# Path: p5/pmath/utils.py
# PI = math.pi


# Path: p5/pmath/tests/test_matrix.py
import unittest
import numpy as np
from p5.pmath import matrix
from p5.pmath.utils import PI


    def test_triple_axis_rotation_matrix(self):
        x = np.array([1, 1, 0])
        y = np.array([0, 1, 0])
        z = np.array([0, 1, 1])

        T = matrix.triple_axis_rotation_matrix(x, y, z)
        R = np.array([
            [1, 1, 0, 0],
            [0, 1, 0, 0],
            [0, 1, 1, 0],
            [0, 0, 0, 1],
        ])
        self.assertTrue(np.array_equal(T, R))

    def test_look_at(self):
        eye = np.array([0, 0, 10])
        at = np.array([0, 0, 0])
        up = np.array([0, 1, 0])

        T = matrix.look_at(eye, at, up)
        R = np.array([
            [1, 0, 0, 0],
            [0, 1, 0, 0],
            [0, 0, 1, -10],
            [0, 0, 0, 1]
        ])
        self.assertTrue(np.array_equal(T, R))

    def test_perspective_matrix(self):

        fov = 2 / 3 * PI