// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movss %xmm3, -0x30(%rbp)
movss %xmm2, -0x6c(%rbp)
movss %xmm1, -0x60(%rbp)
movss %xmm0, -0x38(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
callq 0x6332
leaq 0x684d(%rip), %rax      # 0xfbb8
movq %rax, (%rbx)
movw $0x101, 0x38(%rbx)      # imm = 0x101
movb $0x0, 0x3a(%rbx)
movabsq $0x3e4ccccd3c75c28f, %rax # imm = 0x3E4CCCCD3C75C28F
movq %rax, 0x3c(%rbx)
movaps 0x1f53(%rip), %xmm0     # 0xb2e0
movups %xmm0, 0x20(%rbx)
andq $0x0, 0x30(%rbx)
movq 0x68(%r15), %rcx
movq 0x70(%r15), %rax
cmpq %rcx, %rax
je 0x96bb
movq %rbx, -0x40(%rbp)
leaq 0x68(%rbx), %r14
xorl %r13d, %r13d
leaq -0x50(%rbp), %r12
movl %r13d, %r13d
subq %rcx, %rax
cqto
pushq $0xc
popq %rsi
idivq %rsi
cmpq %r13, %rax
jbe 0x948e
imulq $0xc, %r13, %rax
movl 0x8(%rcx,%rax), %edx
movl %edx, -0x48(%rbp)
movq (%rcx,%rax), %rax
movq %rax, -0x50(%rbp)
movq %r12, %rdi
callq 0x5372
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movaps %xmm2, %xmm3
mulss %xmm2, %xmm3
movaps %xmm0, %xmm4
mulss %xmm0, %xmm4
addss %xmm3, %xmm4
sqrtss %xmm4, %xmm3
cvtss2sd %xmm3, %xmm4
ucomisd 0x1e6f(%rip), %xmm4     # 0xb280
jbe 0x9450
movss 0x1bed(%rip), %xmm4     # 0xb008
divss %xmm3, %xmm4
mulss %xmm4, %xmm0
mulss %xmm2, %xmm4
movss %xmm0, -0x8c(%rbp)
movss %xmm4, -0x88(%rbp)
movss %xmm1, -0x84(%rbp)
movq %r14, %rdi
leaq -0x8c(%rbp), %rsi
callq 0x994e
jmp 0x947e
movq 0x6b71(%rip), %rdi      # 0xffc8
leaq 0x28a9(%rip), %rsi      # 0xbd07
callq 0x31a0
movq %rax, %rbx
movq %r12, %rdi
callq 0x554a
movq %rbx, %rdi
callq 0x3140
movq %rax, %rdi
callq 0x30d0
incl %r13d
movq 0x68(%r15), %rcx
movq 0x70(%r15), %rax
jmp 0x93b6
movss -0x38(%rbp), %xmm0
callq 0x3130
movss %xmm0, -0x68(%rbp)
movss -0x38(%rbp), %xmm0
callq 0x3160
movss %xmm0, -0x64(%rbp)
movss -0x60(%rbp), %xmm0
callq 0x3130
movss %xmm0, -0x2c(%rbp)
movss -0x60(%rbp), %xmm0
callq 0x3160
movss %xmm0, -0x80(%rbp)
movq 0x6af7(%rip), %rdi      # 0xffc8
leaq 0x2842(%rip), %rsi      # 0xbd1a
callq 0x31a0
cvtss2sd -0x60(%rbp), %xmm0
divsd 0x1d76(%rip), %xmm0     # 0xb260
movq %rax, %rdi
callq 0x3200
leaq 0x282a(%rip), %rsi      # 0xbd23
movq %rax, %rdi
callq 0x31a0
cvtss2sd -0x38(%rbp), %xmm0
divsd 0x1d52(%rip), %xmm0     # 0xb260
movq %rax, %rdi
callq 0x3200
leaq 0x2814(%rip), %rsi      # 0xbd31
movq %rax, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30d0
movss -0x6c(%rbp), %xmm2
movss -0x68(%rbp), %xmm1
mulss %xmm2, %xmm1
movss -0x30(%rbp), %xmm3
movss -0x64(%rbp), %xmm0
mulss %xmm3, %xmm0
movss -0x2c(%rbp), %xmm4
mulss %xmm2, %xmm4
movss %xmm4, -0x2c(%rbp)
movss -0x80(%rbp), %xmm2
mulss %xmm3, %xmm2
movss %xmm2, -0x80(%rbp)
callq 0x31d0
movss %xmm0, -0x30(%rbp)
movss -0x80(%rbp), %xmm0
movss -0x2c(%rbp), %xmm1
callq 0x31d0
movapd %xmm0, -0x60(%rbp)
movq 0x6a3e(%rip), %rdi      # 0xffc8
leaq 0x27a5(%rip), %rsi      # 0xbd36
movq -0x40(%rbp), %r12
callq 0x31a0
cvtss2sd -0x60(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
divsd 0x1cb4(%rip), %xmm0     # 0xb260
movq %rax, %rdi
callq 0x3200
leaq 0x2788(%rip), %rsi      # 0xbd43
movq %rax, %rdi
callq 0x31a0
cvtss2sd -0x30(%rbp), %xmm0
divsd 0x1c90(%rip), %xmm0     # 0xb260
movq %rax, %rdi
callq 0x3200
leaq 0x2752(%rip), %rsi      # 0xbd31
movq %rax, %rdi
callq 0x31a0
movq %rax, %rdi
callq 0x30d0
movsd -0x38(%rbp), %xmm0
addsd 0x1c8c(%rip), %xmm0     # 0xb288
cvtsd2ss %xmm0, %xmm0
movaps -0x60(%rbp), %xmm3
movaps %xmm3, %xmm4
movss -0x30(%rbp), %xmm2
cmpltss %xmm2, %xmm4
movaps %xmm4, %xmm1
andnps %xmm3, %xmm1
andps %xmm0, %xmm4
orps %xmm1, %xmm4
ucomiss %xmm2, %xmm4
jbe 0x96da
movq 0x70(%r12), %rax
subq 0x68(%r12), %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
movq %rax, %rbx
subss %xmm2, %xmm4
cvtsi2ss %ebx, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x50(%rbp), %r15
movaps %xmm4, -0x80(%rbp)
testl %ebx, %ebx
js 0x96ac
cvtsi2ss %ebx, %xmm0
mulss %xmm4, %xmm0
divss -0x2c(%rbp), %xmm0
addss %xmm2, %xmm0
movss %xmm0, -0x38(%rbp)
callq 0x3130
movss %xmm0, -0x60(%rbp)
movss -0x38(%rbp), %xmm0
callq 0x3160
movss -0x60(%rbp), %xmm1
movss %xmm1, -0x50(%rbp)
movss %xmm0, -0x4c(%rbp)
movl $0x3f800000, -0x48(%rbp) # imm = 0x3F800000
movq %r14, %rdi
movq %r15, %rsi
callq 0x9f14
decl %ebx
movss -0x30(%rbp), %xmm2
movaps -0x80(%rbp), %xmm4
jmp 0x9650
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x240a(%rip), %rdi      # 0xbacc
leaq 0x1e5b(%rip), %rsi      # 0xb524
leaq 0x25d7(%rip), %rcx      # 0xbca7
movl $0x48c, %edx            # imm = 0x48C
callq 0x3110
leaq 0x2674(%rip), %rdi      # 0xbd55
leaq 0x1e3c(%rip), %rsi      # 0xb524
leaq 0x25b8(%rip), %rcx      # 0xbca7
movl $0x4b1, %edx            # imm = 0x4B1
callq 0x3110
jmp 0x96ff
jmp 0x9706
jmp 0x9706
movq %rax, %rbx
jmp 0x970d
jmp 0x9706
movq %rax, %rbx
movq -0x40(%rbp), %r12
movq %r12, %rdi
callq 0x973c
movq %rbx, %rdi
callq 0x3250
nop