vrshoot

view libs/assimp/assimp/vector2.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2012, assimp team
8 All rights reserved.
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:
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
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.
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.
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 */
41 /** @file aiVector2t.h
42 * @brief 2D vector structure, including operators when compiling in C++
43 */
44 #ifndef AI_VECTOR2D_H_INC
45 #define AI_VECTOR2D_H_INC
47 #include <math.h>
49 #include "./Compiler/pushpack1.h"
51 // ----------------------------------------------------------------------------------
52 /** Represents a two-dimensional vector.
53 */
55 #ifdef __cplusplus
56 template <typename TReal>
57 class aiVector2t
58 {
59 public:
61 aiVector2t () : x(), y() {}
62 aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {}
63 explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {}
64 aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {}
66 public:
68 void Set( TReal pX, TReal pY);
69 TReal SquareLength() const ;
70 TReal Length() const ;
71 aiVector2t& Normalize();
73 public:
75 const aiVector2t& operator += (const aiVector2t& o);
76 const aiVector2t& operator -= (const aiVector2t& o);
77 const aiVector2t& operator *= (TReal f);
78 const aiVector2t& operator /= (TReal f);
80 TReal operator[](unsigned int i) const;
81 TReal& operator[](unsigned int i);
83 bool operator== (const aiVector2t& other) const;
84 bool operator!= (const aiVector2t& other) const;
86 aiVector2t& operator= (TReal f);
87 const aiVector2t SymMul(const aiVector2t& o);
89 template <typename TOther>
90 operator aiVector2t<TOther> () const;
92 TReal x, y;
93 } PACK_STRUCT;
95 typedef aiVector2t<float> aiVector2D;
97 #else
99 struct aiVector2D {
100 float x,y;
101 };
103 #endif // __cplusplus
105 #include "./Compiler/poppack1.h"
107 #endif // AI_VECTOR2D_H_INC