vrshoot

view libs/assimp/assimp/vector3.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 aiVector3D.h
42 * @brief 3D vector structure, including operators when compiling in C++
43 */
44 #ifndef AI_VECTOR3D_H_INC
45 #define AI_VECTOR3D_H_INC
47 #include <math.h>
50 #include "./Compiler/pushpack1.h"
52 #ifdef __cplusplus
54 template<typename TReal> class aiMatrix3x3t;
55 template<typename TReal> class aiMatrix4x4t;
57 // ---------------------------------------------------------------------------
58 /** Represents a three-dimensional vector. */
59 template <typename TReal>
60 class aiVector3t
61 {
62 public:
64 aiVector3t () : x(), y(), z() {}
65 aiVector3t (TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
66 explicit aiVector3t (TReal _xyz) : x(_xyz), y(_xyz), z(_xyz) {}
67 aiVector3t (const aiVector3t& o) : x(o.x), y(o.y), z(o.z) {}
69 public:
71 // combined operators
72 const aiVector3t& operator += (const aiVector3t& o);
73 const aiVector3t& operator -= (const aiVector3t& o);
74 const aiVector3t& operator *= (TReal f);
75 const aiVector3t& operator /= (TReal f);
77 // transform vector by matrix
78 aiVector3t& operator *= (const aiMatrix3x3t<TReal>& mat);
79 aiVector3t& operator *= (const aiMatrix4x4t<TReal>& mat);
81 // access a single element
82 TReal operator[](unsigned int i) const;
83 TReal& operator[](unsigned int i);
85 // comparison
86 bool operator== (const aiVector3t& other) const;
87 bool operator!= (const aiVector3t& other) const;
89 template <typename TOther>
90 operator aiVector3t<TOther> () const;
92 public:
94 /** @brief Set the components of a vector
95 * @param pX X component
96 * @param pY Y component
97 * @param pZ Z component */
98 void Set( TReal pX, TReal pY, TReal pZ);
100 /** @brief Get the squared length of the vector
101 * @return Square length */
102 TReal SquareLength() const;
105 /** @brief Get the length of the vector
106 * @return length */
107 TReal Length() const;
110 /** @brief Normalize the vector */
111 aiVector3t& Normalize();
114 /** @brief Componentwise multiplication of two vectors
115 *
116 * Note that vec*vec yields the dot product.
117 * @param o Second factor */
118 const aiVector3t SymMul(const aiVector3t& o);
120 TReal x, y, z;
121 } PACK_STRUCT;
124 typedef aiVector3t<float> aiVector3D;
126 #else
128 struct aiVector3D {
130 float x,y,z;
131 } PACK_STRUCT;
133 #endif // __cplusplus
135 #include "./Compiler/poppack1.h"
137 #ifdef __cplusplus
141 #endif // __cplusplus
143 #endif // AI_VECTOR3D_H_INC