92 lines
2.8 KiB
Plaintext
92 lines
2.8 KiB
Plaintext
// Filename: lvec2_ops.I
|
|
// Created by: drose (08Mar00)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
#include <math.h>
|
|
|
|
#include "nearly_zero.h"
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: scalar * LVecBase2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType, class NumType2>
|
|
INLINE LVecBase2<NumType>
|
|
operator * (NumType2 scalar, const LVecBase2<NumType> &a) {
|
|
return a * scalar;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: scalar * LPoint2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType, class NumType2>
|
|
INLINE LPoint2<NumType>
|
|
operator * (NumType2 scalar, const LPoint2<NumType> &a) {
|
|
return a * scalar;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: scalar * LVector2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType, class NumType2>
|
|
INLINE LVector2<NumType>
|
|
operator * (NumType2 scalar, const LVector2<NumType> &a) {
|
|
return a * scalar;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: dot product of LVecBase2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType>
|
|
INLINE NumType
|
|
dot(const LVecBase2<NumType> &a, const LVecBase2<NumType> &b) {
|
|
return a.dot(b);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: cross product of LVecBase2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType>
|
|
INLINE LVecBase2<NumType>
|
|
cross(const LVecBase2<NumType> &a, const LVecBase2<NumType> &b) {
|
|
return a.cross(b);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: cross product of LVector2
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType>
|
|
INLINE LVector2<NumType>
|
|
cross(const LVector2<NumType> &a, const LVector2<NumType> &b) {
|
|
return LVector2<NumType>(a.cross(b));
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: length of a vector
|
|
// Description:
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType>
|
|
INLINE NumType
|
|
length(const LVector2<NumType> &a) {
|
|
return a.length();
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: normalize
|
|
// Description: Returns a normalized vector from the given vector.
|
|
////////////////////////////////////////////////////////////////////
|
|
template<class NumType>
|
|
INLINE LVector2<NumType>
|
|
normalize(const LVector2<NumType> &v) {
|
|
LVector2<NumType> v1 = v;
|
|
v1.normalize();
|
|
return v1;
|
|
}
|