1/*
2---------------------------------------------------------------------------
3Open Asset Import Library (assimp)
4---------------------------------------------------------------------------
5
6Copyright (c) 2006-2017, assimp team
7
8
9All rights reserved.
10
11Redistribution and use of this software in source and binary forms,
12with or without modification, are permitted provided that the following
13conditions 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
29THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40---------------------------------------------------------------------------
41*/
42/** @file vector2.h
43 * @brief 2D vector structure, including operators when compiling in C++
44 */
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// ----------------------------------------------------------------------------------
59/** Represents a two-dimensional vector.
60 */
61
62#ifdef __cplusplus
63template <typename TReal>
64class aiVector2t
65{
66public:
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
73public:
74
75 void Set( TReal pX, TReal pY);
76 TReal SquareLength() const ;
77 TReal Length() const ;
78 aiVector2t& Normalize();
79
80public:
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
104typedef aiVector2t<ai_real> aiVector2D;
105
106#else
107
108struct aiVector2D {
109 ai_real x, y;
110};
111
112#endif // __cplusplus
113
114#include "./Compiler/poppack1.h"
115
116#endif // AI_VECTOR2D_H_INC
117