<jupyter_start><jupyter_text>Aula7.Ex3 - A matriz View - Passo a passo  Primeiro, importamos as bibliotecas necessárias.Verifique no código anterior um script para instalar as dependências necessárias (OpenGL e GLFW) antes de prosseguir.<jupyter_code>import numpy as np
import glm
import math<jupyter_output><empty_output><jupyter_text>Calculando Matriz View<jupyter_code>cameraPos = np.array([0.0, 0.0, 0.2])
cameraTarget = np.array([0.0, 0.0, 0.0])
cameraUp = np.array([0.0, 1.0, 1.0])

n = cameraPos-cameraTarget
n = n / np.linalg.norm(n)
n
u = np.cross(cameraUp, n)
u = u / np.linalg.norm(u)
u
v = np.cross(n, u)
v
R = [
        [u[0], u[1], u[2], 0.0],
        [v[0], v[1], v[2], 0.0],
        [n[0], n[1], n[2], 0.0],
        [ 0.0,  0.0,  0.0, 1.0]
    ]

T = [
        [1.0, 0.0, 0.0, -cameraPos[0]],
        [0.0, 1.0, 0.0, -cameraPos[1]],
        [0.0, 0.0, 1.0, -cameraPos[2]],
        [0.0, 0.0, 0.0, 1.0          ],        
    ]

view = np.matmul(T,R)
view<jupyter_output><empty_output><jupyter_text>Calculando Matriz View com GLM<jupyter_code>cameraPos = glm.vec3(0.0, 0.0, 0.2)
cameraTarget = glm.vec3(0.0, 0.0, -1.0)
cameraUp = glm.vec3(0.0, 0.00001, 1.0000)

view = glm.lookAt(cameraPos, cameraTarget, cameraUp)
np.array(view).T<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1833855799373041, 'fraction_numerical': 0.07836990595611286, 'mean_word_length': 3.132686084142395, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '528828', 'license': 'MIT', 'n_tokens_mistral': 626, 'n_tokens_neox': 591, 'n_words': 122, 'path': '4.View/examples/Aula7.Ex3 - A matriz View  - Passo a passo.ipynb', 'repo_name': 'guisoares9/opengl-studies', 'size': '1276'}