// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
leaq 0x28(%rdi), %r15
movsd 0x28(%rdi), %xmm0
ucomisd 0x10f3d3(%rip), %xmm0   # 0x14c008
jne 0x3cc9e
jp 0x3cc9e
leaq 0x5a2a00(%rip), %rsi    # 0x5df640
movq %r15, %rdi
callq 0xd4746
cmpl $0x0, 0x24(%rbx)
jle 0x3cc9e
leaq 0x20(%rsp), %r14
xorl %r13d, %r13d
leaq 0x18(%rsp), %r12
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d2fe
movq %r15, %rdi
movq %r14, %rsi
callq 0xd4d18
movq %r12, %rdi
callq 0x450ee
incq %r13
movslq 0x24(%rbx), %rax
cmpq %rax, %r13
jl 0x3cc5b
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %r15, %rdi
callq 0xd4d96
leaq 0x40(%rbx), %r14
leaq 0x11a0bf(%rip), %rsi    # 0x156d68
movq %r14, %rdi
callq 0xd5124
testl %eax, %eax
je 0x3cd6b
movl 0x24(%rbx), %eax
leal -0x8(%rax), %ecx
cmpl $0x2, %ecx
jb 0x3cd22
addl $-0x6, %eax
cmpl $0x1, %eax
ja 0x3cdc8
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d2fe
leaq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x450fa
leaq 0x11a0ca(%rip), %rsi    # 0x156dc8
movq %rsp, %rdi
leaq 0x58(%rsp), %rdx
callq 0xd57a6
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd55fe
leaq 0x18(%rsp), %rdi
callq 0x450ee
jmp 0x3cd63
movq 0x18(%rbx), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d2fe
movq %rsp, %rdi
movq %r15, %rsi
callq 0x450fa
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd55fe
leaq 0x18(%rsp), %rdi
callq 0x450ee
movq $0x0, 0x50(%rbx)
movq %r14, %rdi
callq 0xd5188
addq $0x58, %rbx
leaq 0x119ff2(%rip), %rsi    # 0x156d68
movq %rbx, %rdi
callq 0xd5124
testl %eax, %eax
je 0x3cdba
leaq 0x11a03f(%rip), %rsi    # 0x156dc8
movq %rsp, %r15
movq %r15, %rdi
callq 0xd4e82
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xd57a6
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd55fe
movq %rbx, %rdi
callq 0xd5188
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x3cd6b
movslq 0x10(%rbx), %rcx
movsd 0x28(%rbx), %xmm0
testq %rcx, %rcx
jle 0x3ce2f
ucomisd 0x10f221(%rip), %xmm0   # 0x14c008
jne 0x3cdeb
jnp 0x3ce2f
movq 0x40(%rax), %rax
movq -0x8(%rax,%rcx,8), %rdi
callq 0x3cf12
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xd43ee
movsd (%r12), %xmm0
ucomisd 0x10f1f1(%rip), %xmm0   # 0x14c008
jne 0x3ce1f
jnp 0x3cd6b
movq %rsp, %r12
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
jmp 0x3ce8e
movl 0x4c(%rax), %edx
decl %edx
cmpl %edx, %ecx
jge 0x3cd6b
ucomisd 0x10f1c4(%rip), %xmm0   # 0x14c008
jne 0x3ce4c
jnp 0x3cd6b
movq 0x40(%rax), %rax
movq 0x8(%rax,%rcx,8), %rdi
callq 0x3cf12
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xd43ee
movsd (%r12), %xmm0
ucomisd 0x10f190(%rip), %xmm0   # 0x14c008
jne 0x3ce80
jnp 0x3cd6b
movq %rsp, %r12
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xd463a
movq %r14, %rdi
movq %r12, %rsi
callq 0xd55fe
jmp 0x3cd5b
jmp 0x3cea7
jmp 0x3cea7
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x450ee
movq %rbx, %rdi
callq 0x28150