1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxvector2.h
13#ifndef _FBXSDK_CORE_MATH_VECTOR_2_H_
14#define _FBXSDK_CORE_MATH_VECTOR_2_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/fbxsdk_nsbegin.h>
19
20/** A two double mathematic vector class.
21 * \nosubgrouping
22 */
23class FBXSDK_DLL FbxVector2 : public FbxDouble2
24{
25public:
26 /**
27 * \name Constructors and Destructor
28 */
29 //@{
30 //! Constructor.
31 FbxVector2();
32
33 /** Copy constructor.
34 * \param pVector2 The vector copied to this one.
35 */
36 FbxVector2(const FbxVector2& pVector2);
37
38 /** Constructor.
39 * \param pX X component.
40 * \param pY Y component.
41 */
42 FbxVector2(double pX, double pY);
43 //@}
44
45 /**
46 * \name Access
47 */
48 //@{
49 /** Assignment operation.
50 * \param pVector2 The vector assigned to this one.
51 * \return This vector after assignment.
52 */
53 FbxVector2& operator=(const FbxVector2& pVector2);
54
55 /** Set vector.
56 * \param pX The X component value.
57 * \param pY The Y component value.
58 */
59 void Set(double pX, double pY);
60 //@}
61
62 /**
63 * \name Scalar Operations
64 */
65 //@{
66 /** Add a value to all vector components.
67 * \param pValue The value to add to each component of the vector.
68 * \return A new vector with the result of adding pValue to each component of this vector.
69 * \remarks The pValue parameter is not checked.
70 */
71 FbxVector2 operator+(double pValue) const;
72
73 /** Subtract a value from all vector components.
74 * \param pValue The value to subtract from each component of the vector.
75 * \return A new vector with the result of subtracting pValue from each component of this vector.
76 * \remarks The pValue parameter is not checked.
77 */
78 FbxVector2 operator-(double pValue) const;
79
80 /** Multiply a value to all vector components.
81 * \param pValue The value multiplying each component of the vector.
82 * \return A new vector with the result of multiplying each component of this vector by pValue.
83 * \remarks The pValue parameter is not checked.
84 */
85 FbxVector2 operator*(double pValue) const;
86
87 /** Divide all vector components by a value.
88 * \param pValue The value dividing each component of the vector.
89 * \return A new vector with the result of dividing each component of this vector by pValue.
90 * \remarks The pValue parameter is not checked.
91 */
92 FbxVector2 operator/(double pValue) const;
93
94 /** Add a value to all vector components.
95 * \param pValue The value to add to each component of the vector.
96 * \return The result of adding pValue to each component of this vector, replacing this vector.
97 * \remarks The pValue parameter is not checked.
98 */
99 FbxVector2& operator+=(double pValue);
100
101 /** Subtract a value from all vector components.
102 * \param pValue The value to subtract from each component of the vector.
103 * \return The result of subtracting pValue from each component of this vector, replacing this vector.
104 * \remarks The pValue parameter is not checked.
105 */
106 FbxVector2& operator-=(double pValue);
107
108 /** Multiply a value to all vector elements.
109 * \param pValue The value multiplying each component of the vector.
110 * \return The result of multiplying each component of this vector by pValue, replacing this vector.
111 * \remarks The pValue parameter is not checked.
112 */
113 FbxVector2& operator*=(double pValue);
114
115 /** Divide all vector elements by a value.
116 * \param pValue The value dividing each component of the vector.
117 * \return The result of multiplying each component of this vector by pValue, replacing this vector.
118 * \remarks The pValue parameter is not checked.
119 */
120 FbxVector2& operator/=(double pValue);
121 //@}
122
123 /**
124 * \name Vector Operations
125 */
126 //@{
127 /** Unary minus operator.
128 * \return The vector that is the negation of \c this.
129 */
130 FbxVector2 operator-() const;
131
132 /** Add two vectors together.
133 * \param pVector Vector to add.
134 * \return The result of this vector + pVector.
135 * \remarks The values in pVector are not checked.
136 */
137 FbxVector2 operator+(const FbxVector2& pVector) const;
138
139 /** Subtract a vector from another vector.
140 * \param pVector Vector to subtract.
141 * \return The result of this vector - pVector.
142 * \remarks The values in pVector are not checked.
143 */
144 FbxVector2 operator-(const FbxVector2& pVector) const;
145
146 /** Memberwise multiplication of two vectors.
147 * \param pVector Multiplying vector.
148 * \return The result of this vector * pVector.
149 * \remarks The values in pVector are not checked.
150 */
151 FbxVector2 operator*(const FbxVector2& pVector) const;
152
153 /** Memberwise division of a vector with another vector.
154 * \param pVector Dividing vector.
155 * \return The result of this vector / pVector.
156 * \remarks The values in pVector are not checked.
157 */
158 FbxVector2 operator/(const FbxVector2& pVector) const;
159
160 /** Add two vectors together.
161 * \param pVector Vector to add.
162 * \return The result of this vector + pVector, replacing this vector.
163 * \remarks The values in pVector are not checked.
164 */
165 FbxVector2& operator+=(const FbxVector2& pVector);
166
167 /** Subtract a vector from another vector.
168 * \param pVector Vector to subtract.
169 * \return The result of this vector - pVector, replacing this vector.
170 * \remarks The values in pVector are not checked.
171 */
172 FbxVector2& operator-=(const FbxVector2& pVector);
173
174 /** Memberwise multiplication of two vectors.
175 * \param pVector Multiplying vector.
176 * \return The result of this vector * pVector, replacing this vector.
177 * \remarks The values in pVector are not checked.
178 */
179 FbxVector2& operator*=(const FbxVector2& pVector);
180
181 /** Memberwise division of a vector with another vector.
182 * \param pVector Dividing vector.
183 * \remarks The values in pVector are not checked.
184 * \return The result of this vector / pVector, replacing this vector.
185 * \remarks The values in pVector are not checked.
186 */
187 FbxVector2& operator/=(const FbxVector2& pVector);
188
189 /** Calculate the dot product of two vectors.
190 * \param pVector The second vector.
191 * \return The dot product value.
192 */
193 double DotProduct(const FbxVector2& pVector) const;
194 //@}
195
196 /**
197 * \name Boolean Operations
198 */
199 //@{
200 /** Equivalence operator.
201 * \param pVector The vector to be compared to \e this.
202 * \return \c true if the two vectors are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c false otherwise.
203 */
204 bool operator==(const FbxVector2 & pVector) const;
205
206 /** Non-equivalence operator.
207 * \param pVector The vector to be compared to \e this.
208 * \return \c false if the two vectors are equal (each element is within a FBXSDK_TOLERANCE tolerance), \c true otherwise.
209 */
210 bool operator!=(const FbxVector2 & pVector) const;
211 //@}
212
213 /**
214 * \name Length
215 */
216 //@{
217 /** Get the vector's length.
218 * \return The mathematical length of the vector.
219 */
220 double Length() const;
221
222 /** Get the vector's length squared.
223 * \return The mathematical square length of the vector.
224 */
225 double SquareLength() const;
226
227 /** Find the distance between 2 vectors.
228 * \param pVector The second vector.
229 * \return The mathematical distance between the two vectors.
230 */
231 double Distance(const FbxVector2& pVector) const;
232
233 //! Normalize the vector, length set to 1.
234 void Normalize();
235 //@}
236
237 /**
238 * \name Casting
239 */
240 //@{
241 //! Cast the vector in a double pointer.
242 operator double* ();
243
244 //! Cast the vector in a const double pointer.
245 operator const double* () const;
246 //@}
247
248 /** Find out if the vector is equal to zero.
249 * \param pSize The number of element to test, starting at beginning. Value must range between [1, 2].
250 * \return \c true if all elements of the vector are zero, \c false otherwise. */
251 bool IsZero(int pSize=2) const;
252
253 // Fix value like 1.#IND, 1.#INF, nan, and inf
254 void FixIncorrectValue();
255};
256
257#include <fbxsdk/fbxsdk_nsend.h>
258
259#endif /* _FBXSDK_CORE_MATH_VECTOR_2_H_ */
260