// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVPanorama.cpp
// Function: gaps::GSVPanorama::UpdatePose()
void GSVPanorama::
UpdatePose(void) 
{
  // Update viewpoint
  if (viewpoint[0] == FLT_MAX) {
    viewpoint = R3zero_point;
    if (NImages() > 0) {
      for (int i = 0; i < NImages(); i++) 
        viewpoint += Image(i)->Pose().Viewpoint();
      viewpoint /= NImages();
    }
  }

  // Update front vector
  if (front == R3zero_vector) {
    if ((NImages() == 7) || (NImages() == 6)) {
      // Herschel (with or without sky camera)
      front = R3posz_vector % Image(1)->Pose().Towards();
      front.Normalize();
    }
    else if ((NImages() == 9) || (NImages() == 8)) {
      // R7 (with or without sky camera)
      front = Image(0)->Pose().Towards();
      front[2] = 0;
      front.Normalize();
    }
    else if (Segment() && (SegmentIndex() > 0) && (viewpoint[0] != FLT_MAX)) {
      // Based on viewpoint change from previous panorama
      GSVPanorama *panoramaA = Segment()->Panorama(SegmentIndex()-1);
      R3Point viewpointA = panoramaA->Viewpoint();
      if (viewpointA[0] != FLT_MAX) {
        front = viewpoint - viewpointA;
        front[2] = 0;
        front.Normalize();
      }
    }
    else if (Segment() && (SegmentIndex() < Segment()->NPanoramas()-1) && (viewpoint[0] != FLT_MAX)) {
      // Based on viewpoint change from next panorama
      GSVPanorama *panoramaB = Segment()->Panorama(SegmentIndex()+1);
      R3Point viewpointB = panoramaB->Viewpoint();
      if (viewpointB[0] != FLT_MAX) {
        front = viewpointB - viewpoint;
        front[2] = 0;
        front.Normalize();
      }
    }
  }

  // Update right vector
  if (right == R3zero_vector) {
    right = front % Up();
    right.Normalize();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x28(%rdi), %r15
movsd 0x28(%rdi), %xmm0
ucomisd 0xf0928(%rip), %xmm0    # 0x12b028
jne 0x3a76b
jp 0x3a76b
leaq 0x58df55(%rip), %rsi    # 0x5c8660
movq %r15, %rdi
callq 0xc10e6
movl 0x24(%rbx), %eax
testl %eax, %eax
jle 0x3a76b
leaq 0x28(%rsp), %r14
xorl %r13d, %r13d
leaq 0x20(%rsp), %r12
pushq $-0x1
popq %rbp
movslq %eax, %rcx
cmpq %rcx, %r13
jge 0x3a75f
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movl %ebp, %edx
callq 0x3acd2
movq %r15, %rdi
movq %r14, %rsi
callq 0xc1466
movq %r12, %rdi
callq 0x41e6a
incq %r13
movl 0x24(%rbx), %eax
jmp 0x3a72a
cvtsi2sd %eax, %xmm0
movq %r15, %rdi
callq 0xc14e4
leaq 0x40(%rbx), %r14
leaq 0xfb522(%rip), %rsi     # 0x135c98
movq %r14, %rdi
callq 0xc185c
testl %eax, %eax
je 0x3a839
movl 0x24(%rbx), %eax
leal -0x8(%rax), %ecx
cmpl $0x2, %ecx
jb 0x3a7f1
addl $-0x6, %eax
cmpl $0x1, %eax
ja 0x3a899
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x20(%rsp), %r15
pushq $-0x1
popq %rdx
movq %r15, %rdi
callq 0x3acd2
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x41e74
leaq 0xfb52f(%rip), %rsi     # 0x135cf8
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xc1c6e
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xc1b2c
leaq 0x20(%rsp), %rdi
callq 0x41e6a
jmp 0x3a831
movq 0x18(%rbx), %rax
movq (%rax), %rsi
leaq 0x20(%rsp), %r15
pushq $-0x1
popq %rdx
movq %r15, %rdi
callq 0x3acd2
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x41e74
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xc1b2c
leaq 0x20(%rsp), %rdi
callq 0x41e6a
andq $0x0, 0x50(%rbx)
movq %r14, %rdi
callq 0xc18be
addq $0x58, %rbx
leaq 0xfb454(%rip), %rsi     # 0x135c98
movq %rbx, %rdi
callq 0xc185c
testl %eax, %eax
je 0x3a88a
leaq 0xfb4a1(%rip), %rsi     # 0x135cf8
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xc15cc
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xc1c6e
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc1b2c
movq %rbx, %rdi
callq 0xc18be
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x3a839
movslq 0x10(%rbx), %rcx
movsd 0x28(%rbx), %xmm0
testq %rcx, %rcx
jle 0x3a902
ucomisd 0xf0770(%rip), %xmm0    # 0x12b028
jne 0x3a8bc
jnp 0x3a902
movq 0x40(%rax), %rax
movq -0x8(%rax,%rcx,8), %rdi
callq 0x35e94
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xc0e0c
movsd (%r12), %xmm0
ucomisd 0xf0740(%rip), %xmm0    # 0x12b028
jne 0x3a8f0
jnp 0x3a839
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
jmp 0x3a963
movl 0x4c(%rax), %edx
decl %edx
cmpl %edx, %ecx
jge 0x3a839
ucomisd 0xf0711(%rip), %xmm0    # 0x12b028
jne 0x3a91f
jnp 0x3a839
movq 0x40(%rax), %rax
movq 0x8(%rax,%rcx,8), %rdi
callq 0x35e94
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xc0e0c
movsd (%r12), %xmm0
ucomisd 0xf06dd(%rip), %xmm0    # 0x12b028
jne 0x3a953
jnp 0x3a839
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xc0fd9
movq %r14, %rdi
movq %r12, %rsi
callq 0xc1b2c
jmp 0x3a82c
jmp 0x3a97c
jmp 0x3a97c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x41e6a
movq %rbx, %rdi
callq 0x28170
nop