fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / tools / source / generic / point.cxx
blob7feaef6a2083a9b543fd9a310677011a46b0c829
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <numeric>
22 #include <tools/gen.hxx>
23 #include <basegfx/numeric/ftools.hxx>
25 void Point::RotateAround( long& rX, long& rY,
26 short nOrientation ) const
28 const long nOriginX = X();
29 const long nOriginY = Y();
31 if ( (nOrientation >= 0) && !(nOrientation % 900) )
33 if ( (nOrientation >= 3600) )
34 nOrientation %= 3600;
36 if ( nOrientation )
38 rX -= nOriginX;
39 rY -= nOriginY;
41 if ( nOrientation == 900 )
43 long nTemp = rX;
44 rX = rY;
45 rY = -nTemp;
47 else if ( nOrientation == 1800 )
49 rX = -rX;
50 rY = -rY;
52 else /* ( nOrientation == 2700 ) */
54 long nTemp = rX;
55 rX = -rY;
56 rY = nTemp;
59 rX += nOriginX;
60 rY += nOriginY;
63 else
65 double nRealOrientation = nOrientation*F_PI1800;
66 double nCos = cos( nRealOrientation );
67 double nSin = sin( nRealOrientation );
69 // Translation...
70 long nX = rX-nOriginX;
71 long nY = rY-nOriginY;
73 // Rotation...
74 rX = +((long)(nCos*nX + nSin*nY)) + nOriginX;
75 rY = -((long)(nSin*nX - nCos*nY)) + nOriginY;
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */