// File: /workspace/github_cpp_makefile_star2_O1/carlos-urena[P]svg-gen/svgobjects.cpp
// Function: ZCylinderPolygonWithSector::ZCylinderPolygonWithSector(Polygon const&, float, float, float, float)
ZCylinderPolygonWithSector::ZCylinderPolygonWithSector( const Polygon & orig,
                                                         real ang0, real ang1,
                                                         real lonX, real lonY  )
{
   style.draw_lines   = true ;
   style.draw_filled  = false ;
   style.close_lines  = true ;
   style.lines_width  = 0.015 ;
   style.fill_opacity = 0.2 ;
   style.lines_color  = vec3( 1.0, 0.0, 0.0 );
   style.fill_color   = vec3( 1.0, 0.0, 0.0 );

   assert( orig.points3D.size() > 0 );
   for( unsigned i = 0 ; i < orig.points3D.size() ; i++ )
   {

      const vec3 porig = orig.points3D[i] ;
      const vec3 pesf  = porig.normalized();
      const real len   = real(sqrt( double( pesf[0]*pesf[0]+pesf[1]*pesf[1] ))) ;

      if ( len > 1e-6 )
      {
         const real f    = real(1.0)/len;
         const vec3 pcil = vec3(  f*pesf[0], f*pesf[1], pesf[2]) ;
         points3D.push_back( pcil );
      }
      else
      {
         using namespace std ;
         cout << "porig.length() == " << porig.length() << endl ;
      }
  }

  // añadir el sector

  using namespace std ;

  vec2 p0 = vec2( lonX*cos(ang0), lonY*sin(ang0)),
       p1 = vec2( lonX*cos(ang1), lonY*sin(ang1));


  cout << "ang1 == " << ang1/M_PI  << "*pi, ang0 == " << ang0/M_PI << "*pi " << endl ;

  real ang0corr = atan2( p0[1], p0[0] ),
       ang1corr = atan2( p1[1], p1[0] );
  cout << "ang1 (c) == " << ang1corr/M_PI  << "*pi, ang0 (c) == " << ang0corr/M_PI << "*pi " << endl ;
  // insertar points en el borde del cilindro, desde ang1 (incluido) hasta ang0 (sin incluir)

  if (ang1corr < ang0corr ) ang1corr += 2.0*M_PI ; // corrige ang1 para saltar discontinuidades de atan2, por si acaso ;
  assert( ang0corr < ang1corr ); // check

  const int nump = points3D.size() ;

  for( int i = nump ; 0 <= i ; i-- )
  {
    const real ang = ang0corr + (ang1corr-ang0corr)*real(i)/real(nump) ;
    points3D.push_back( vec3( cos(ang), sin(ang), 1.0 ) );
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movss %xmm3, -0x8c(%rbp)
movss %xmm2, -0x88(%rbp)
movss %xmm1, -0x80(%rbp)
movss %xmm0, -0x2c(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
xorl %r14d, %r14d
movb %r14b, 0x8(%rdi)
leaq 0x5ec3(%rip), %rax      # 0x11760
movq %rax, (%rdi)
addq $0x20, %rdi
callq 0x6c48
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x68(%rbx)
leaq 0x62fe(%rip), %rax      # 0x11bc0
movq %rax, (%rbx)
movw $0x101, 0x38(%rbx)      # imm = 0x101
movb %r14b, 0x3a(%rbx)
movabsq $0x3e4ccccd3c75c28f, %rax # imm = 0x3E4CCCCD3C75C28F
movq %rax, 0x3c(%rbx)
movapd 0x198b(%rip), %xmm0     # 0xd270
movupd %xmm0, 0x20(%rbx)
movq $0x0, 0x30(%rbx)
movq 0x70(%r15), %rax
cmpq 0x68(%r15), %rax
je 0xbde9
leaq 0x68(%rbx), %rax
movq %rax, -0xa0(%rbp)
movq 0x68(%r15), %rax
cmpq %rax, 0x70(%r15)
je 0xbafe
xorl %r14d, %r14d
movq 0x66ad(%rip), %r13      # 0x11fd0
leaq (%r14,%r14,2), %rcx
movl 0x8(%rax,%rcx,4), %edx
movl %edx, -0x90(%rbp)
movq (%rax,%rcx,4), %rax
movq %rax, -0x98(%rbp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
cvtss2sd -0x98(%rbp,%rax,4), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0xb942
cvtsd2ss %xmm0, %xmm0
ucomiss 0x1942(%rip), %xmm0     # 0xd2ac
jb 0xb972
sqrtss %xmm0, %xmm0
jmp 0xb977
callq 0x32d0
xorl %eax, %eax
movss -0x98(%rbp,%rax,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, -0x38(%rbp,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0xb979
movsd -0x38(%rbp), %xmm3
movss -0x30(%rbp), %xmm2
movaps %xmm3, %xmm4
shufps $0x55, %xmm3, %xmm4     # xmm4 = xmm4[1,1],xmm3[1,1]
movaps %xmm4, %xmm1
mulss %xmm4, %xmm1
movaps %xmm3, %xmm0
mulss %xmm3, %xmm0
addss %xmm1, %xmm0
ucomiss 0x18ed(%rip), %xmm0     # 0xd2ac
jb 0xb9c7
sqrtss %xmm0, %xmm0
jmp 0xb9e6
movss %xmm2, -0x50(%rbp)
movaps %xmm3, -0x60(%rbp)
movaps %xmm4, -0x70(%rbp)
callq 0x32d0
movaps -0x70(%rbp), %xmm4
movaps -0x60(%rbp), %xmm3
movss -0x50(%rbp), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
ucomisd 0x1813(%rip), %xmm1     # 0xd208
jbe 0xba3f
movss 0x1609(%rip), %xmm1     # 0xd008
divss %xmm0, %xmm1
mulss %xmm1, %xmm3
mulss %xmm4, %xmm1
movss %xmm3, -0x38(%rbp)
movss %xmm1, -0x34(%rbp)
movss %xmm2, -0x30(%rbp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0xbac5
movl -0x30(%rbp), %eax
movl %eax, 0x8(%rsi)
movq -0x38(%rbp), %rax
movq %rax, (%rsi)
addq $0xc, 0x70(%rbx)
jmp 0xbad5
movl $0x12, %edx
movq %r13, %rdi
leaq 0x2245(%rip), %rsi      # 0xdc93
callq 0x31e0
xorps %xmm0, %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
cvtss2sd -0x98(%rbp,%rax,4), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0xba58
cvtsd2ss %xmm0, %xmm0
ucomiss 0x182c(%rip), %xmm0     # 0xd2ac
jb 0xba88
sqrtss %xmm0, %xmm0
jmp 0xba8d
callq 0x32d0
cvtss2sd %xmm0, %xmm0
movq %r13, %rdi
callq 0x3250
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0xbad5
movq -0xa0(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0xc67c
incl %r14d
movq 0x68(%r15), %rax
movq 0x70(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %r14, %rcx
ja 0xb923
movss -0x2c(%rbp), %xmm0
callq 0x3150
movss %xmm0, -0x70(%rbp)
movss -0x2c(%rbp), %xmm0
callq 0x3180
movss %xmm0, -0x84(%rbp)
movss -0x80(%rbp), %xmm0
callq 0x3150
movss %xmm0, -0x50(%rbp)
movss -0x80(%rbp), %xmm0
callq 0x3180
movss %xmm0, -0x60(%rbp)
movq 0x648c(%rip), %rdi      # 0x11fd0
leaq 0x215b(%rip), %rsi      # 0xdca6
movl $0x8, %edx
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x80(%rbp), %xmm0
divsd 0x1683(%rip), %xmm0     # 0xd1e8
movq 0x6464(%rip), %rdi      # 0x11fd0
callq 0x3250
movq %rax, %r15
leaq 0x2134(%rip), %rsi      # 0xdcaf
movl $0xd, %edx
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x2c(%rbp), %xmm0
divsd 0x1650(%rip), %xmm0     # 0xd1e8
movq %r15, %rdi
callq 0x3250
movq %rax, %r15
leaq 0x2113(%rip), %rsi      # 0xdcbd
movl $0x4, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movss -0x88(%rbp), %xmm2
movss -0x70(%rbp), %xmm1
mulss %xmm2, %xmm1
movss -0x8c(%rbp), %xmm3
movss -0x84(%rbp), %xmm0
mulss %xmm3, %xmm0
movss -0x50(%rbp), %xmm4
mulss %xmm2, %xmm4
movss %xmm4, -0x50(%rbp)
movss -0x60(%rbp), %xmm2
mulss %xmm3, %xmm2
movss %xmm2, -0x60(%rbp)
callq 0x3200
movss %xmm0, -0x70(%rbp)
movss -0x60(%rbp), %xmm0
movss -0x50(%rbp), %xmm1
callq 0x3200
movapd %xmm0, -0x50(%rbp)
movq 0x638c(%rip), %rdi      # 0x11fd0
leaq 0x2077(%rip), %rsi      # 0xdcc2
movl $0xc, %edx
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x50(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
divsd 0x157e(%rip), %xmm0     # 0xd1e8
movq 0x635f(%rip), %rdi      # 0x11fd0
callq 0x3250
movq %rax, %r15
leaq 0x204f(%rip), %rsi      # 0xdccf
movl $0x11, %edx
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x70(%rbp), %xmm0
divsd 0x154b(%rip), %xmm0     # 0xd1e8
movq %r15, %rdi
callq 0x3250
movq %rax, %r15
leaq 0x200e(%rip), %rsi      # 0xdcbd
movl $0x4, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movsd -0x60(%rbp), %xmm0
addsd 0x1520(%rip), %xmm0     # 0xd210
cvtsd2ss %xmm0, %xmm0
movaps -0x50(%rbp), %xmm3
movaps %xmm3, %xmm4
movss -0x70(%rbp), %xmm2
cmpltss %xmm2, %xmm4
movaps %xmm4, %xmm1
andnps %xmm3, %xmm1
andps %xmm0, %xmm4
orps %xmm1, %xmm4
movaps %xmm4, -0x80(%rbp)
ucomiss %xmm2, %xmm4
jbe 0xbe08
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %r14d # imm = 0xAAAAAAAB
testl %r14d, %r14d
movq -0xa0(%rbp), %r12
js 0xbdda
movaps -0x80(%rbp), %xmm0
subss -0x70(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x38(%rbp), %r15
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
mulss -0x80(%rbp), %xmm0
divss -0x2c(%rbp), %xmm0
addss -0x70(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
callq 0x3150
movss %xmm0, -0x50(%rbp)
movss -0x60(%rbp), %xmm0
callq 0x3180
movss -0x50(%rbp), %xmm1
movss %xmm1, -0x38(%rbp)
movss %xmm0, -0x34(%rbp)
movl $0x3f800000, -0x30(%rbp) # imm = 0x3F800000
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0xbdc3
movl -0x30(%rbp), %eax
movl %eax, 0x8(%rsi)
movq -0x38(%rbp), %rax
movq %rax, (%rsi)
addq $0xc, 0x70(%rbx)
jmp 0xbdce
movq %r12, %rdi
movq %r15, %rdx
callq 0xc4f4
leal -0x1(%r14), %eax
testl %r14d, %r14d
movl %eax, %r14d
jg 0xbd5f
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c68(%rip), %rdi      # 0xda58
leaq 0x16b9(%rip), %rsi      # 0xd4b0
leaq 0x1e35(%rip), %rcx      # 0xdc33
movl $0x48c, %edx            # imm = 0x48C
callq 0x3120
leaq 0x1ed2(%rip), %rdi      # 0xdce1
leaq 0x169a(%rip), %rsi      # 0xd4b0
leaq 0x1e16(%rip), %rcx      # 0xdc33
movl $0x4b1, %edx            # imm = 0x4B1
callq 0x3120
jmp 0xbe2f
jmp 0xbe2f
jmp 0xbe2f
jmp 0xbe2f
movq %rax, %r14
movq %rbx, %rdi
callq 0xbe68
movq %r14, %rdi
callq 0x32b0