// File: IsaacLaw12[P]RayTracer/./src/Model.cpp
// Function: Model::calculate_face_normals()
void Model::calculate_face_normals(){
    /*
      Calculate the normal for each face by taking the cross product of two of the triangle's sides
    */
    FaceNormals = Eigen::MatrixXd();
    Eigen::Vector3d first_vertex, second_vertex, third_vertex;
    Eigen::Vector3d first_vector, second_vector;
    for (int i=0; i<Faces.cols(); i++){
        first_vertex << get_vertex( Faces(0, i) - 1 );
        second_vertex << get_vertex( Faces(1, i) - 1 );
        third_vertex << get_vertex( Faces(2, i) - 1 );
        // Calculate normal in counter clockwise direction?
        first_vector = first_vertex - third_vertex;
        second_vector = first_vertex - second_vertex;

        add_face_normal((-1*first_vector.cross(second_vector)).normalized());
    }
}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x1e0(%rsp)
movq 0x1e0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x6060
movq 0x8(%rsp), %rdi
addq $0x1c8, %rdi            # imm = 0x1C8
leaq 0x1c8(%rsp), %rsi
callq 0x60c0
leaq 0x1c8(%rsp), %rdi
callq 0x60b0
leaq 0x1b0(%rsp), %rdi
callq 0x11e20
leaq 0x198(%rsp), %rdi
callq 0x11e20
leaq 0x180(%rsp), %rdi
callq 0x11e20
leaq 0x168(%rsp), %rdi
callq 0x11e20
leaq 0x150(%rsp), %rdi
callq 0x11e20
movl $0x0, 0x14c(%rsp)
movq 0x8(%rsp), %rdi
movslq 0x14c(%rsp), %rax
movq %rax, (%rsp)
addq $0x1b0, %rdi            # imm = 0x1B0
callq 0x1da50
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jge 0x1b5dc
movq 0x8(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movslq 0x14c(%rsp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x1da60
movq 0x8(%rsp), %rsi
movl (%rax), %edx
subl $0x1, %edx
leaq 0x110(%rsp), %rdi
callq 0x1b8f0
leaq 0x128(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x1e150
leaq 0x128(%rsp), %rdi
callq 0x120e0
movq 0x8(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movslq 0x14c(%rsp), %rdx
movl $0x1, %esi
callq 0x1da60
movq 0x8(%rsp), %rsi
movl (%rax), %edx
subl $0x1, %edx
leaq 0xd8(%rsp), %rdi
callq 0x1b8f0
leaq 0xf0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x1e150
leaq 0xf0(%rsp), %rdi
callq 0x120e0
movq 0x8(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movslq 0x14c(%rsp), %rdx
movl $0x2, %esi
callq 0x1da60
movq 0x8(%rsp), %rsi
movl (%rax), %edx
subl $0x1, %edx
leaq 0xa0(%rsp), %rdi
callq 0x1b8f0
leaq 0xb8(%rsp), %rdi
leaq 0x180(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x1e150
leaq 0xb8(%rsp), %rdi
callq 0x120e0
leaq 0x88(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
leaq 0x180(%rsp), %rdx
callq 0x9e80
leaq 0x168(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1e190
leaq 0x70(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
leaq 0x198(%rsp), %rdx
callq 0x9e80
leaq 0x150(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1e190
movl $0xffffffff, 0x2c(%rsp) # imm = 0xFFFFFFFF
leaq 0x10(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0xa000
leaq 0x30(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x12100
leaq 0x58(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1e1c0
movq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1b850
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x1b3cb
addq $0x1e8, %rsp            # imm = 0x1E8
retq
nopw %cs:(%rax,%rax)