40 #ifndef __MO_MATH_VECTOR_H__
41 #define __MO_MATH_VECTOR_H__
61 m_afTuple[0] = afTuple[0];
62 m_afTuple[1] = afTuple[1];
68 m_afTuple[0] = rkV.m_afTuple[0];
69 m_afTuple[1] = rkV.m_afTuple[1];
73 inline operator const Real* ()
const {
return m_afTuple; }
74 inline operator Real* () {
return m_afTuple; }
75 inline Real
operator[] (
int i)
const {
return m_afTuple[i]; }
77 inline Real
X ()
const {
return m_afTuple[0]; }
78 inline Real&
X () {
return m_afTuple[0]; }
79 inline Real
Y ()
const {
return m_afTuple[1]; }
80 inline Real&
Y () {
return m_afTuple[1]; }
85 m_afTuple[0] = rkV.m_afTuple[0];
86 m_afTuple[1] = rkV.m_afTuple[1];
101 return moVector2(m_afTuple[0]+rkV.m_afTuple[0], m_afTuple[1]+rkV.m_afTuple[1]);
106 return moVector2(m_afTuple[0]-rkV.m_afTuple[0], m_afTuple[1]-rkV.m_afTuple[1]);
115 if (fScalar != (Real)0.0)
117 Real fInvScalar = ((Real)1.0)/fScalar;
118 kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0];
119 kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1];
137 m_afTuple[0] += rkV.m_afTuple[0];
138 m_afTuple[1] += rkV.m_afTuple[1];
143 m_afTuple[0] -= rkV.m_afTuple[0];
144 m_afTuple[1] -= rkV.m_afTuple[1];
149 m_afTuple[0] *= fScalar;
150 m_afTuple[1] *= fScalar;
154 if (fScalar != (Real)0.0)
156 Real fInvScalar = ((Real)1.0)/fScalar;
157 m_afTuple[0] *= fInvScalar;
158 m_afTuple[1] *= fInvScalar;
174 return m_afTuple[0]*m_afTuple[0] + m_afTuple[1]*m_afTuple[1];
177 return m_afTuple[0]*rkV.m_afTuple[0] + m_afTuple[1]*rkV.m_afTuple[1];
180 Real fLength = Length();
184 Real fInvLength = ((Real)1.0)/fLength;
185 m_afTuple[0] *= fInvLength;
186 m_afTuple[1] *= fInvLength;
191 m_afTuple[0] = (Real)0.0;
192 m_afTuple[1] = (Real)0.0;
206 moVector2 kPerp(m_afTuple[1],-m_afTuple[0]);
213 return m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0];
219 const moVector2& rkV2, Real afBary[3])
const {
232 Real fMax = (Real)0.0;
234 for (i = 0; i < 2; i++)
236 for (
int j = 0; j < 2; j++)
247 if (fMax > (Real)1.0)
249 Real fInvMax = ((Real)1.0)/fMax;
250 for (i = 0; i < 3; i++)
252 akDiff[i] *= fInvMax;
256 Real fDet = akDiff[0].
DotPerp(akDiff[1]);
259 Real fInvDet = ((Real)1.0)/fDet;
260 afBary[0] = akDiff[2].
DotPerp(akDiff[1])*fInvDet;
261 afBary[1] = akDiff[0].
DotPerp(akDiff[2])*fInvDet;
262 afBary[2] = (Real)1.0 - afBary[0] - afBary[1];
272 if (fSqrLength > fMaxSqrLength)
275 fMaxSqrLength = fSqrLength;
278 if (fSqrLength > fMaxSqrLength)
281 fMaxSqrLength = fSqrLength;
286 Real fInvSqrLength = ((Real)1.0)/fMaxSqrLength;
290 afBary[0] = akDiff[2].
Dot(akDiff[0])*fInvSqrLength;
291 afBary[1] = (Real)0.0;
292 afBary[2] = (Real)1.0 - afBary[0];
294 else if (iMaxIndex == 1)
297 afBary[0] = (Real)0.0;
298 afBary[1] = akDiff[2].
Dot(akDiff[1])*fInvSqrLength;
299 afBary[2] = (Real)1.0 - afBary[1];
304 akDiff[2] = *
this - rkV1;
305 afBary[0] = akDiff[2].
Dot(kE2)*fInvSqrLength;
306 afBary[1] = (Real)1.0 - afBary[0];
307 afBary[2] = (Real)0.0;
313 afBary[0] = ((Real)1.0)/(Real)3.0;
314 afBary[1] = afBary[0];
315 afBary[2] = afBary[0];
339 Real fDot0 = rkU.
Dot(rkV);
357 if (!(iVQuantity > 0 && akPoint))
return;
361 for (
int i = 1; i < iVQuantity; i++)
364 for (
int j = 0; j < 2; j++)
366 if (rkPoint[j] < rkMin[j])
368 rkMin[j] = rkPoint[j];
370 else if (rkPoint[j] > rkMax[j])
372 rkMax[j] = rkPoint[j];
382 if ((0 < l) && (0 < lv))
return Dot(rkV) / (l * lv);
398 int CompareArrays (
const moVector2& rkV)
const
400 return memcmp(m_afTuple,rkV.m_afTuple,2*
sizeof(Real));
408 template <
class Real>
419 #endif // MO_RASPBIAN
bool operator<=(const moMatrix3 &rkM) const
static const moVector2 ZERO
Real Cosine(const moVector2< Real > &rkV)
moVector2(Real fX, Real fY)
static void ComputeExtremes(int iVQuantity, const moVector2 *akPoint, moVector2 &rkMin, moVector2 &rkMax)
moMatrix3 operator-(const moMatrix3 &rkM) const
static Real ACos(Real fValue)
moMatrix3 operator/(Real fScalar) const
bool operator>(const moMatrix3 &rkM) const
moVector2 UnitPerp() const
returns (y,-x)/sqrt(x*x+y*y)
static void Orthonormalize(moVector2 &rkU, moVector2 &rkV)
Clase base abstracta de donde deben derivar los objetos [virtual pura].
moVector2< MOfloat > moVector2f
static const moVector2 UNIT_Y
moDeclareExportedDynamicArray(moVector2i, moVector2iArray)
moMatrix3 & operator-=(const moMatrix3 &rkM)
void GetBarycentrics(const moVector2 &rkV0, const moVector2 &rkV1, const moVector2 &rkV2, Real afBary[3]) const
bool operator==(const moMatrix3 &rkM) const
static Real Sqrt(Real fValue)
static const moVector2 ONE
bool operator<(const moMatrix3 &rkM) const
moMatrix3 & operator/=(Real fScalar)
moVector2< MOlong > moVector2i
Real Dot(const moVector2 &rkV) const
bool operator!=(const moMatrix3 &rkM) const
moVector2< MOdouble > moVector2d
static const moVector2 UNIT_X
moMatrix3 & operator*=(Real fScalar)
bool operator>=(const moMatrix3 &rkM) const
moMatrix3 & operator=(const moMatrix3 &rkM)
Real SquaredLength() const
moVector2(const Real *afTuple)
moVector2< Real > operator*(Real fScalar, const moVector2< Real > &rkV)
Real DotPerp(const moVector2 &rkV) const
returns DotPerp((x,y),(V.x,V.y)) = x*V.y - y*V.x
Real Angle(const moVector2< Real > &rkV)
moVector2 Perp() const
returns (y,-x)
static void GenerateOrthonormalBasis(moVector2 &rkU, moVector2 &rkV)
moMatrix3 operator+(const moMatrix3 &rkM) const
static Real FAbs(Real fValue)
moMatrix3 & operator+=(const moMatrix3 &rkM)
moVector2(const moVector2 &rkV)
const Real * operator[](int iRow) const