/src/libreoffice/basegfx/source/vector/b2ivector.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <basegfx/vector/b2ivector.hxx> |
21 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
22 | | #include <basegfx/numeric/ftools.hxx> |
23 | | #include <cassert> |
24 | | |
25 | | namespace basegfx |
26 | | { |
27 | | B2IVector& B2IVector::operator=( const ::basegfx::B2ITuple& rVec ) |
28 | 0 | { |
29 | 0 | mnX = rVec.getX(); |
30 | 0 | mnY = rVec.getY(); |
31 | 0 | return *this; |
32 | 0 | } |
33 | | |
34 | | B2IVector& B2IVector::operator*=( const B2DHomMatrix& rMat ) |
35 | 0 | { |
36 | 0 | mnX = fround( rMat.get(0,0)*mnX + |
37 | 0 | rMat.get(0,1)*mnY ); |
38 | 0 | mnY = fround( rMat.get(1,0)*mnX + |
39 | 0 | rMat.get(1,1)*mnY ); |
40 | |
|
41 | 0 | return *this; |
42 | 0 | } |
43 | | |
44 | | B2IVector& B2IVector::setLength(double fLen) |
45 | 0 | { |
46 | 0 | double fLenNow(std::hypot(mnX, mnY)); |
47 | |
|
48 | 0 | if(!::basegfx::fTools::equalZero(fLenNow)) |
49 | 0 | { |
50 | 0 | assert(fLenNow != 0 && "help coverity see it's not zero"); |
51 | |
|
52 | 0 | const double fOne(1.0); |
53 | |
|
54 | 0 | if(!::basegfx::fTools::equal(fOne, fLenNow)) |
55 | 0 | { |
56 | 0 | fLen /= fLenNow; |
57 | 0 | } |
58 | |
|
59 | 0 | mnX = fround( mnX*fLen ); |
60 | 0 | mnY = fround( mnY*fLen ); |
61 | 0 | } |
62 | |
|
63 | 0 | return *this; |
64 | 0 | } |
65 | | |
66 | | } // end of namespace basegfx |
67 | | |
68 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |