// File: thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::Rotate(double)
Polygon *Polygon::Rotate(double angle)
{
Polygon *Rotated = new Polygon;
double cos_a = cos(angle);
double sin_a = sin(angle);
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;

    nbRotatedPoly++;
    nbCreatedRotatedPoly++;
    Rotated->TypePoly = RotatedPoly;
    if ( poly_centroid_ok == 0 ) getCentroid();
    Rotated->precision = precision;
    Rotated->pt_Translation = pt_Translation;
    Rotated->_Vertices = _Vertices;          //      Copy vertice vector
    Rotated->nVertices = Rotated->_Vertices.size();

    for ( int i = 0; i < nVertices; i++)
    {
        double newx = (_Vertices[i].x - poly_centroid.x) * cos_a - (_Vertices[i].y - poly_centroid.y)* sin_a + poly_centroid.x;
        newx = round(newx/precision)*precision;
        Rotated->_Vertices[i].x = newx;
        double newy = (_Vertices[i].x - poly_centroid.x) * sin_a + (_Vertices[i].y - poly_centroid.y)* cos_a + poly_centroid.y;
        newy = round(newy/precision)*precision;
        Rotated->_Vertices[i].y = newy;
        if ( i == 0 )
        {
            xmin = newx;
            xmax = newx;
            ymin = newy;
            ymax = newy;
        }
        else
        {
            if ( newx < xmin ) xmin = newx;
            if ( newy < ymin ) ymin = newy;
            if ( newx > xmax ) xmax = newx;
            if ( newy > ymax ) ymax = newy;
        }
    }
    Rotated->BoundingBox.A = Point(xmin, ymin);
    Rotated->BoundingBox.B = Point(xmax, ymax);
    Rotated->poly_area = poly_area;
    Rotated->poly_centroid = poly_centroid;
    Rotated->angle_rotation = angle;
    Rotated->poly_centroid_ok = 1;
    Rotated->poly_changed = 0;
    Rotated->poly_closed = poly_closed;
    Rotated->poly_clockwise = poly_clockwise;
    return Rotated;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0xc0, %edi
callq 0x9550
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
callq 0x5e600
jmp 0x61f0d
movq -0xa8(%rbp), %rax
movq %rax, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x99f0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x9120
movq -0xb0(%rbp), %rax
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x56bfc(%rip), %rcx     # 0xb8b60
addq $0x1, %rcx
movq %rcx, 0x56bf1(%rip)     # 0xb8b60
movq 0x56c1a(%rip), %rcx     # 0xb8b90
addq $0x1, %rcx
movq %rcx, 0x56c0f(%rip)     # 0xb8b90
movq -0x18(%rbp), %rcx
movl $0x2, 0xc(%rcx)
cmpl $0x0, 0x90(%rax)
jne 0x61fcf
movq -0xb0(%rbp), %rdi
callq 0x615a0
movsd %xmm0, -0x68(%rbp)
movsd %xmm1, -0x60(%rbp)
jmp 0x61fcf
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0xc0, %esi
callq 0x9560
jmp 0x623a8
movq -0xb0(%rbp), %rsi
movsd 0xa0(%rsi), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0xa0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rsi), %rcx
movq %rcx, 0xb0(%rax)
movq 0xb8(%rsi), %rcx
movq %rcx, 0xb8(%rax)
addq $0x10, %rsi
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x642a0
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x6c(%rbp)
movq -0xb0(%rbp), %rcx
movl -0x6c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x622b9
movq -0xb0(%rbp), %rdi
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movq -0xb0(%rbp), %rdi
movsd (%rax), %xmm0
subsd 0x80(%rdi), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movsd -0xe0(%rbp), %xmm0
movsd -0xd8(%rbp), %xmm2
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movsd 0x8(%rcx), %xmm1
subsd 0x88(%rax), %xmm1
mulsd -0x38(%rbp), %xmm1
movq %xmm1, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd 0x80(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
divsd 0xa0(%rax), %xmm0
callq 0x9220
movq -0xb0(%rbp), %rax
mulsd 0xa0(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movsd -0xd0(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movq -0xb0(%rbp), %rdi
movsd (%rax), %xmm0
subsd 0x80(%rdi), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movsd -0xc8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm2
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movsd 0x8(%rcx), %xmm1
subsd 0x88(%rax), %xmm1
mulsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd 0x88(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
divsd 0xa0(%rax), %xmm0
callq 0x9220
movq -0xb0(%rbp), %rax
mulsd 0xa0(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x63990
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, 0x8(%rax)
cmpl $0x0, -0x6c(%rbp)
jne 0x62247
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x622a9
movsd -0x78(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x62261
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x80(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6227b
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x78(%rbp), %xmm0
ucomisd -0x48(%rbp), %xmm0
jbe 0x62291
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x80(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x622a7
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x622a9
jmp 0x622ab
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x62038
movsd -0x40(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
leaq -0x90(%rbp), %rdi
callq 0x5b520
movq -0x18(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x60(%rax)
movsd -0x48(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
leaq -0xa0(%rbp), %rdi
callq 0x5b520
movq -0xb0(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0xa0(%rbp), %rdx
movq %rdx, 0x68(%rcx)
movq -0x98(%rbp), %rdx
movq %rdx, 0x70(%rcx)
movsd 0x78(%rax), %xmm0
movq -0x18(%rbp), %rcx
movsd %xmm0, 0x78(%rcx)
movq -0x18(%rbp), %rcx
movq 0x80(%rax), %rdx
movq %rdx, 0x80(%rcx)
movq 0x88(%rax), %rdx
movq %rdx, 0x88(%rcx)
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rcx
movsd %xmm0, 0xa8(%rcx)
movq -0x18(%rbp), %rcx
movl $0x1, 0x90(%rcx)
movq -0x18(%rbp), %rcx
movl $0x0, 0x9c(%rcx)
movl 0x98(%rax), %edx
movq -0x18(%rbp), %rcx
movl %edx, 0x98(%rcx)
movl 0x94(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x94(%rax)
movq -0x18(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x9960
nopw %cs:(%rax,%rax)