1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <basegfx/tuple/Size2D.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/vector/b2isize.hxx>
25 #include <basegfx/numeric/ftools.hxx>
26 #include <basegfx/basegfxdllapi.h>
30 class B2DSize
: public Size2D
<double>
38 B2DSize(double fX
, double fY
)
43 B2DSize(Size2D
<double> const& rSize
)
48 explicit B2DSize(B2ISize
const& rSize
)
49 : Size2D(rSize
.getX(), rSize
.getY())
53 /** Transform size by given transformation matrix. */
54 B2DSize
& operator*=(const B2DHomMatrix
& rMatrix
)
56 const double fTempX(rMatrix
.get(0, 0) * getWidth() + rMatrix
.get(0, 1) * getHeight());
57 const double fTempY(rMatrix
.get(1, 0) * getWidth() + rMatrix
.get(1, 1) * getHeight());
63 using Size2D
<double>::operator+=;
64 using Size2D
<double>::operator-=;
65 using Size2D
<double>::operator*=;
66 using Size2D
<double>::operator/=;
67 using Size2D
<double>::operator-;
69 double getLength() const
71 if (fTools::equalZero(getWidth()))
73 return fabs(getHeight());
75 else if (fTools::equalZero(getHeight()))
77 return fabs(getWidth());
80 return hypot(getWidth(), getHeight());
84 inline B2DSize
operator*(B2DHomMatrix
const& rMatrix
, B2DSize
const& rSize
)
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */