// File: /workspace/github_cpp_makefile_star2_O1/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 0xfdd10(%rip), %rax     # 0x12f3a8
movq %rax, (%rdi)
leaq 0x8(%rdi), %r13
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
mulsd 0xaca91(%rip), %xmm0    # 0xde140
movsd %xmm0, 0x30(%rsp)
movsd %xmm1, 0x40(%rsp)
divsd %xmm1, %xmm0
callq 0x13410
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd %xmm0, 0x58(%rsp)
mulsd 0xaca67(%rip), %xmm1    # 0xde140
movsd %xmm1, 0x28(%rsp)
movapd %xmm1, %xmm0
divsd 0x8(%rsp), %xmm0
callq 0x13410
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 0x6b818
leaq 0x150(%rbp), %r13
movq %r13, %rdi
callq 0x73050
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 0x317c8
movsd 0x30(%rsp), %xmm4
movsd %xmm4, 0x1e8(%rbp)
ucomisd %xmm3, %xmm0
jb 0x317dc
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rbp)
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x317f9
leaq 0x10341b(%rip), %rax    # 0x134c08
movsd (%rax), %xmm1
movsd %xmm1, 0x1f8(%rbp)
ucomisd %xmm2, %xmm0
jb 0x31812
leaq 0x103412(%rip), %rax    # 0x134c18
movsd (%rax), %xmm0
movsd %xmm0, 0x200(%rbp)
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x71906
leaq 0xe8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq 0x38(%rsp), %rsi
callq 0x71408
leaq 0x68(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x714b6
leaq 0x68(%rsp), %rsi
movq %r13, %rdi
callq 0x74c36
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3186e
jmp 0x3186e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
callq 0x6ede0
movq %rbx, %rdi
callq 0x138b0
nop