// File: 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:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x210(%rsp)
movq 0x210(%rsp), %rdi
movq %rdi, 0x48(%rsp)
addq $0x28, %rdi
xorl %esi, %esi
callq 0x44530
movsd (%rax), %xmm0
movsd 0x217345(%rip), %xmm1   # 0x266018
ucomisd %xmm1, %xmm0
jne 0x4edf1
jp 0x4edf1
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
leaq 0x6b45ad(%rip), %rsi    # 0x7032a0
callq 0x180420
movq 0x48(%rsp), %rdi
callq 0x3a2e0
cmpl $0x0, %eax
jle 0x4edef
movl $0x0, 0x20c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x20c(%rsp), %eax
movl %eax, 0x44(%rsp)
callq 0x3a2e0
movl %eax, %ecx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x4edd3
movq 0x48(%rsp), %rdi
movl 0x20c(%rsp), %esi
callq 0x3a300
movq %rax, %rsi
leaq 0x1c8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4faf0
movq 0x30(%rsp), %rdi
callq 0x3a330
movq %rax, 0x38(%rsp)
jmp 0x4ed75
movq 0x38(%rsp), %rsi
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
callq 0x180a60
jmp 0x4ed8a
leaq 0x1c8(%rsp), %rdi
callq 0x5e680
movl 0x20c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20c(%rsp)
jmp 0x4ed16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x5e680
jmp 0x4f297
movq 0x48(%rsp), %rdi
callq 0x3a2e0
movq 0x48(%rsp), %rdi
cvtsi2sd %eax, %xmm0
addq $0x28, %rdi
callq 0x180ba0
jmp 0x4edf1
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
leaq 0x6b458f(%rip), %rsi    # 0x703390
callq 0x181550
cmpl $0x0, %eax
je 0x4f227
movq 0x48(%rsp), %rdi
callq 0x3a2e0
cmpl $0x7, %eax
je 0x4ee31
movq 0x48(%rsp), %rdi
callq 0x3a2e0
cmpl $0x6, %eax
jne 0x4eeea
movq 0x48(%rsp), %rdi
movl $0x1, %esi
callq 0x3a300
movq %rax, %rsi
leaq 0x148(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4faf0
movq 0x28(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0x5e6c0
jmp 0x4ee6e
leaq 0x6b457b(%rip), %rsi    # 0x7033f0
leaq 0x1a0(%rsp), %rdi
leaq 0x188(%rsp), %rdx
callq 0x181d30
jmp 0x4ee8c
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x181bb0
jmp 0x4eea4
leaq 0x148(%rsp), %rdi
callq 0x5e680
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
callq 0x181650
jmp 0x4f225
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x5e680
jmp 0x4f297
movq 0x48(%rsp), %rdi
callq 0x3a2e0
cmpl $0x9, %eax
je 0x4ef0c
movq 0x48(%rsp), %rdi
callq 0x3a2e0
cmpl $0x8, %eax
jne 0x4efbe
movq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x3a300
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4faf0
movq 0x20(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x5e6c0
jmp 0x4ef46
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
leaq 0x130(%rsp), %rsi
callq 0x181bb0
jmp 0x4ef5e
leaq 0xf0(%rsp), %rdi
callq 0x5e680
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
movl $0x2, %esi
callq 0x4a710
movq 0x48(%rsp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
addq $0x40, %rdi
callq 0x181650
jmp 0x4f223
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x5e680
jmp 0x4f297
movq 0x48(%rsp), %rdi
callq 0x47d30
cmpq $0x0, %rax
je 0x4f0e1
movq 0x48(%rsp), %rdi
callq 0x4a680
cmpl $0x0, %eax
jle 0x4f0e1
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
callq 0x44530
movsd (%rax), %xmm0
movsd 0x217017(%rip), %xmm1   # 0x266018
ucomisd %xmm1, %xmm0
jne 0x4f00e
jp 0x4f00e
jmp 0x4f0e1
movq 0x48(%rsp), %rdi
callq 0x47d30
movq 0x48(%rsp), %rdi
movq %rax, 0x18(%rsp)
callq 0x4a680
movq 0x18(%rsp), %rdi
movl %eax, %esi
subl $0x1, %esi
callq 0x3a2b0
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x44d40
movq %rax, %rsi
leaq 0xd0(%rsp), %rdi
callq 0x17fdd0
leaq 0xd0(%rsp), %rdi
xorl %esi, %esi
callq 0x44530
movsd (%rax), %xmm0
movsd 0x216fa2(%rip), %xmm1   # 0x266018
ucomisd %xmm1, %xmm0
jne 0x4f080
jp 0x4f080
jmp 0x4f0dc
movq 0x48(%rsp), %rsi
addq $0x28, %rsi
leaq 0xb8(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0x1800f0
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x181bb0
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
movl $0x2, %esi
callq 0x4a710
movq 0x48(%rsp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
addq $0x40, %rdi
callq 0x181650
jmp 0x4f221
movq 0x48(%rsp), %rdi
callq 0x47d30
cmpq $0x0, %rax
je 0x4f21f
movq 0x48(%rsp), %rdi
callq 0x4a680
movq 0x48(%rsp), %rdi
movl %eax, 0x14(%rsp)
callq 0x47d30
movq %rax, %rdi
callq 0x3a290
movl %eax, %ecx
movl 0x14(%rsp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x4f21f
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
callq 0x44530
movsd (%rax), %xmm0
movsd 0x216ed6(%rip), %xmm1   # 0x266018
ucomisd %xmm1, %xmm0
jne 0x4f14f
jp 0x4f14f
jmp 0x4f21f
movq 0x48(%rsp), %rdi
callq 0x47d30
movq 0x48(%rsp), %rdi
movq %rax, 0x8(%rsp)
callq 0x4a680
movq 0x8(%rsp), %rdi
movl %eax, %esi
addl $0x1, %esi
callq 0x3a2b0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x44d40
movq %rax, %rsi
leaq 0x98(%rsp), %rdi
callq 0x17fdd0
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0x44530
movsd (%rax), %xmm0
movsd 0x216e61(%rip), %xmm1   # 0x266018
ucomisd %xmm1, %xmm0
jne 0x4f1c1
jp 0x4f1c1
jmp 0x4f21d
movq 0x48(%rsp), %rdx
addq $0x28, %rdx
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1800f0
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
leaq 0x80(%rsp), %rsi
callq 0x181bb0
movq 0x48(%rsp), %rdi
addq $0x40, %rdi
movl $0x2, %esi
callq 0x4a710
movq 0x48(%rsp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
addq $0x40, %rdi
callq 0x181650
jmp 0x4f21f
jmp 0x4f221
jmp 0x4f223
jmp 0x4f225
jmp 0x4f227
movq 0x48(%rsp), %rdi
addq $0x58, %rdi
leaq 0x6b4159(%rip), %rsi    # 0x703390
callq 0x181550
cmpl $0x0, %eax
je 0x4f28f
movq 0x48(%rsp), %rsi
movq %rsi, %rax
addq $0x40, %rax
movq %rax, (%rsp)
leaq 0x50(%rsp), %rdi
callq 0x4f420
movq (%rsp), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x181d30
movq 0x48(%rsp), %rdi
addq $0x58, %rdi
leaq 0x68(%rsp), %rsi
callq 0x181bb0
movq 0x48(%rsp), %rdi
addq $0x58, %rdi
callq 0x181650
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x1c0(%rsp), %rdi
callq 0x29c10
nopw %cs:(%rax,%rax)