BRE12
vector2.h
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
44 #ifndef AI_VECTOR2D_H_INC
45 #define AI_VECTOR2D_H_INC
46 
47 #ifdef __cplusplus
48 # include <cmath>
49 #else
50 # include <math.h>
51 #endif
52 
53 #include "./Compiler/pushpack1.h"
54 
55 // ----------------------------------------------------------------------------------
59 #ifdef __cplusplus
60 template <typename TReal>
61 class aiVector2t
62 {
63 public:
64 
65  aiVector2t () : x(), y() {}
66  aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {}
67  explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {}
68  aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {}
69 
70 public:
71 
72  void Set( TReal pX, TReal pY);
73  TReal SquareLength() const ;
74  TReal Length() const ;
75  aiVector2t& Normalize();
76 
77 public:
78 
79  const aiVector2t& operator += (const aiVector2t& o);
80  const aiVector2t& operator -= (const aiVector2t& o);
81  const aiVector2t& operator *= (TReal f);
82  const aiVector2t& operator /= (TReal f);
83 
84  TReal operator[](unsigned int i) const;
85  TReal& operator[](unsigned int i);
86 
87  bool operator== (const aiVector2t& other) const;
88  bool operator!= (const aiVector2t& other) const;
89 
90  bool Equal(const aiVector2t& other, TReal epsilon = 1e-6) const;
91 
92  aiVector2t& operator= (TReal f);
93  const aiVector2t SymMul(const aiVector2t& o);
94 
95  template <typename TOther>
96  operator aiVector2t<TOther> () const;
97 
98  TReal x, y;
99 } PACK_STRUCT;
100 
101 typedef aiVector2t<float> aiVector2D;
102 
103 #else
104 
105 struct aiVector2D {
106  float x,y;
107 };
108 
109 #endif // __cplusplus
110 
111 #include "./Compiler/poppack1.h"
112 
113 #endif // AI_VECTOR2D_H_INC
Represents a two-dimensional vector.
Definition: vector2.h:105