// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelConstraint.cpp
// Function: gaps::R3SurfelViewConstraint::R3SurfelViewConstraint(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Vector const&, int, int, double, double, double, double, double, double, gaps::R2Grid const*, int)
R3SurfelViewConstraint::
R3SurfelViewConstraint(const R3Point& world_viewpoint,
  const R3Vector& world_towards, const R3Vector& world_up,
  int w, int h, RNScalar fx, RNScalar fy, RNScalar cx, RNScalar cy,
  RNLength neardist, RNLength fardist, 
  const R2Grid *image_mask,
  RNBoolean must_be_inside_frustum)
  : frustum(world_viewpoint, world_towards, world_up, atan(0.5*w/fx), atan(0.5*h/fy), neardist, fardist),
    world_to_camera(),
    w(w), h(h),
    fx(fx), fy(fy),
    cx(cx), cy(cy),
    neardist(neardist), fardist(fardist),
    image_mask(image_mask),
    must_be_inside_frustum(must_be_inside_frustum)
{
  // Compute default image center
  if (this->cx <= 0) this->cx = 0.5*w;
  if (this->cy <= 0) this->cy = 0.5*h;

  // Compute default near and far distances
  if (this->neardist <= 0) this->neardist = RN_EPSILON;
  if (this->fardist <= 0) this->fardist = RN_INFINITY;

  // Compute world_to_camera matrix
  R3CoordSystem cs(world_viewpoint, R3Triad(world_towards, world_up));
  world_to_camera = cs.InverseMatrix();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movsd %xmm5, 0x18(%rsp)
movsd %xmm4, 0x10(%rsp)
movsd %xmm3, 0x50(%rsp)
movsd %xmm2, 0x48(%rsp)
movsd %xmm1, 0x8(%rsp)
movapd %xmm0, %xmm1
movl %r9d, %ebx
movl %r8d, %r14d
movq %rcx, 0x60(%rsp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbp
leaq 0xf1152(%rip), %rax     # 0x11f3b8
movq %rax, (%rdi)
leaq 0x8(%rdi), %r13
cvtsi2sd %r8d, %xmm0
mulsd 0x99ebe(%rip), %xmm0    # 0xc8138
movsd %xmm0, 0x30(%rsp)
movsd %xmm1, 0x40(%rsp)
divsd %xmm1, %xmm0
callq 0x13420
cvtsi2sd %ebx, %xmm1
movsd %xmm0, 0x58(%rsp)
mulsd 0x99e97(%rip), %xmm1    # 0xc8138
movsd %xmm1, 0x28(%rsp)
movapd %xmm1, %xmm0
divsd 0x8(%rsp), %xmm0
callq 0x13420
movapd %xmm0, %xmm1
movq %r13, 0x20(%rsp)
movq %r13, %rdi
movq %r15, 0x38(%rsp)
movq %r15, %rsi
movq 0x60(%rsp), %r15
movq %r12, %rdx
movq %r15, %rcx
movsd 0x58(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
callq 0x6184a
leaq 0x150(%rbp), %r13
movq %r13, %rdi
callq 0x6878a
movl 0x188(%rsp), %eax
movq 0x180(%rsp), %rcx
movl %r14d, 0x1d0(%rbp)
movl %ebx, 0x1d4(%rbp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x1d8(%rbp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x1e0(%rbp)
movsd 0x48(%rsp), %xmm4
movsd %xmm4, 0x1e8(%rbp)
movsd 0x50(%rsp), %xmm3
movsd %xmm3, 0x1f0(%rbp)
movsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x1f8(%rbp)
movsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x200(%rbp)
movq %rcx, 0x208(%rbp)
movl %eax, 0x210(%rbp)
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm0
jb 0x2e390
movsd 0x30(%rsp), %xmm4
movsd %xmm4, 0x1e8(%rbp)
ucomisd %xmm3, %xmm0
jb 0x2e3a4
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rbp)
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x2e3c1
leaq 0xf6873(%rip), %rax     # 0x124c28
movsd (%rax), %xmm1
movsd %xmm1, 0x1f8(%rbp)
ucomisd %xmm2, %xmm0
jb 0x2e3da
leaq 0xf686a(%rip), %rax     # 0x124c38
movsd (%rax), %xmm0
movsd %xmm0, 0x200(%rbp)
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x67374
leaq 0xe8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq 0x38(%rsp), %rsi
callq 0x66f12
leaq 0x68(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x66f9c
leaq 0x68(%rsp), %rsi
movq %r13, %rdi
callq 0x69e14
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e436
jmp 0x2e436
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0x649ae
movq %rbx, %rdi
callq 0x138f0
nop