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