// File: Lut99[P]RayTracer/src/lib/Camera.cpp
// Function: RayTracer::Camera::recompute()
void Camera::recompute() {
    double ratio = (double) this->width / (double) this->height;
    double focus_dist = (this->lookfrom - this->lookat).length();
    this->lens_radius = this->aperture / 2;

    double theta = this->vfov * M_PI / 180;
    double half_height = tan(theta/2);
    double half_width = ratio * half_height;

    this->origin = this->lookfrom;
    this->w = (this->lookfrom - this->lookat).normalize();
    this->u = cross(this->up, this->w).normalize();
    this->v = cross(this->w, this->u);

    this->lower_left_corner = this->origin - half_width * focus_dist * this->u - half_height * focus_dist *  this->v - focus_dist * this->w;
    this->horizontal = 2 * half_width * focus_dist * this->u;
    this->vertical = 2 * half_height * focus_dist * this->v;
}

// Assembly:
subq $0x208, %rsp            # imm = 0x208
movq %rdi, 0x200(%rsp)
movq 0x200(%rsp), %rdx
movq %rdx, 0x10(%rsp)
cvtsi2sdl 0x8(%rdx), %xmm0
cvtsi2sdl 0xc(%rdx), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq %rdx, %rsi
addq $0x20, %rsi
addq $0x40, %rdx
leaq 0x1d0(%rsp), %rdi
callq 0x1558e0
leaq 0x1d0(%rsp), %rdi
callq 0x154e70
movq 0x10(%rsp), %rax
movsd %xmm0, 0x1f0(%rsp)
movsd 0x88(%rax), %xmm0
movsd 0xf19a(%rip), %xmm1     # 0x170060
divsd %xmm1, %xmm0
movsd %xmm0, 0x170(%rax)
movsd 0x171f6(%rip), %xmm0    # 0x1780d0
mulsd 0x80(%rax), %xmm0
movsd 0x171de(%rip), %xmm1    # 0x1780c8
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movsd 0x1c8(%rsp), %xmm0
movsd 0xf158(%rip), %xmm1     # 0x170060
divsd %xmm1, %xmm0
callq 0xd0310
movq 0x10(%rsp), %rdi
movsd %xmm0, 0x1c0(%rsp)
movsd 0x1f8(%rsp), %xmm0
mulsd 0x1c0(%rsp), %xmm0
movsd %xmm0, 0x1b8(%rsp)
movq %rdi, %rsi
addq $0x20, %rsi
addq $0xf0, %rdi
callq 0x1547a0
movq 0x10(%rsp), %rdx
movq %rdx, %rsi
addq $0x20, %rsi
addq $0x40, %rdx
leaq 0x178(%rsp), %rdi
callq 0x1558e0
leaq 0x198(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x154ee0
movq 0x10(%rsp), %rdi
addq $0x130, %rdi            # imm = 0x130
leaq 0x198(%rsp), %rsi
callq 0x1547a0
movq 0x10(%rsp), %rdx
movq %rdx, %rsi
addq $0x60, %rsi
addq $0x130, %rdx            # imm = 0x130
leaq 0x138(%rsp), %rdi
callq 0x155cd0
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x154ee0
movq 0x10(%rsp), %rdi
addq $0x110, %rdi            # imm = 0x110
leaq 0x158(%rsp), %rsi
callq 0x1547a0
movq 0x10(%rsp), %rdx
movq %rdx, %rsi
addq $0x130, %rsi            # imm = 0x130
addq $0x110, %rdx            # imm = 0x110
leaq 0x118(%rsp), %rdi
callq 0x155cd0
movq 0x10(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
leaq 0x118(%rsp), %rsi
callq 0x1547a0
movq 0x10(%rsp), %rsi
movq %rsi, %rax
addq $0xf0, %rax
movq %rax, 0x8(%rsp)
movsd 0x1b8(%rsp), %xmm0
mulsd 0x1f0(%rsp), %xmm0
addq $0x110, %rsi            # imm = 0x110
leaq 0x98(%rsp), %rdi
callq 0x155ae0
movq 0x8(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1558e0
movq 0x10(%rsp), %rsi
movsd 0x1c0(%rsp), %xmm0
mulsd 0x1f0(%rsp), %xmm0
addq $0x150, %rsi            # imm = 0x150
leaq 0x78(%rsp), %rdi
callq 0x155ae0
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x1558e0
movq 0x10(%rsp), %rsi
movsd 0x1f0(%rsp), %xmm0
addq $0x130, %rsi            # imm = 0x130
leaq 0x58(%rsp), %rdi
callq 0x155ae0
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x1558e0
movq 0x10(%rsp), %rdi
addq $0x90, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x1547a0
movq 0x10(%rsp), %rsi
movsd 0xef4a(%rip), %xmm0     # 0x170060
mulsd 0x1b8(%rsp), %xmm0
mulsd 0x1f0(%rsp), %xmm0
addq $0x110, %rsi            # imm = 0x110
leaq 0x38(%rsp), %rdi
callq 0x155ae0
movq 0x10(%rsp), %rdi
addq $0xb0, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1547a0
movq 0x10(%rsp), %rsi
movsd 0xef04(%rip), %xmm0     # 0x170060
mulsd 0x1c0(%rsp), %xmm0
mulsd 0x1f0(%rsp), %xmm0
addq $0x150, %rsi            # imm = 0x150
leaq 0x18(%rsp), %rdi
callq 0x155ae0
movq 0x10(%rsp), %rdi
addq $0xd0, %rdi
leaq 0x18(%rsp), %rsi
callq 0x1547a0
addq $0x208, %rsp            # imm = 0x208
retq
nopl (%rax)