24 #include <boost/foreach.hpp>
50 #define EPSILON_4 (decimal)0.0001
60 (decimal)0.000000000000001
65 #define M_PI (decimal)3.141592653589793238462643383279
68 #define M_PIDIV2 (decimal)1.570796326794896619231321691639
71 #define M_2PI (decimal)6.283185307179586476925286766559
75 #define M_4PI (decimal)12.566370614359172953850573533118
78 #define M_PI2 (decimal)9.869604401089358618834490999876
79 #define M_PIDIV180 (decimal)0.01745329251994329576923690768488
80 #define M_180DIVPI (decimal)57.295779513082320876798154814105
82 #define DegToRad(a) a *= M_PIDIV180
83 #define RadToDeg(a) a *= M_180DIVPI
84 #define RADIANS(a) a* M_PIDIV180
85 #define DEGRES(a) a* M_180DIVPI
86 #define ABS(x) (fabs(x))
89 #define SIGN(x) ((x) > 0 ? 1 : -1)
111 base_vec3(
const base_t& _x,
const base_t& _y,
const base_t& _z) :
x(_x),
y(_y),
z(_z) {}
117 :
x(_w.
x - _v.
x),
y(_w.
y - _v.
y),
z(_w.
z - _v.
z) {}
140 return !(*
this == _v);
152 return base_vec3(this->
x * _f, this->
y * _f, this->
z * _f);
169 return base_vec3(this->
x + _v.
x, this->y + _v.
y, this->z + _v.
z);
177 return base_vec3(this->
x - _v.
x, this->y - _v.
y, this->z - _v.
z);
182 return *
this = *
this * _f;
186 return *
this = *
this / _f;
190 return *
this = *
this + _v;
194 return *
this = *
this - _v;
199 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z;
203 return base_vec3(this->
y * _v.
z - this->z * _v.
y, this->z * _v.
x - this->x * _v.
z,
204 this->x * _v.
y - this->y * _v.
x);
213 operator const base_t*()
const
228 return (fabs(this->
x - _v.
x) < 0.5 && fabs(this->
y - _v.
y) < 0.5 && fabs(this->
z - _v.
z) < 0.5);
230 void set(base_t _x, base_t _y, base_t _z)
238 this->
x = this->
y = this->
z = 0;
242 return sqrtf(this->
x * this->
x + this->
y * this->
y + this->
z * this->
z);
246 base_t inv, l = this->
length();
259 this->
x = v1.
y * v2.
z - v1.
z * v2.
y;
260 this->
y = v1.
z * v2.
x - v1.
x * v2.
z;
261 this->
z = v1.
x * v2.
y - v1.
y * v2.
x;
265 base_t
x = this->
y * v2.
z - this->
z * v2.
y;
266 base_t
y = this->
z * v2.
x - this->x * v2.
z;
267 this->
z = this->x * v2.
y - this->y * v2.
x;
273 return (this->
x * ac.
x + this->y * ac.
y + this->z * ac.
z) / (
length() * ac.
length());
277 return ((this->
x * v.
x) + (this->y *
v.y) + (this->z *
v.z));
282 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi && fabs(this->
z - _v.
z) < epsi);
311 return (((vB - vA) * factor) + vA);
317 return v.dot(*
this - vA) /
v.dot(
v);
322 return ((u * (1 - factor)) + (
v * factor));
338 return (sqrt(dx * dx + dy * dy + dz * dz));
351 base_t m1 = cos(
angle);
353 base_t m3 = sin(
angle);
355 base_t m2nx = m2 * n.
x;
357 return base_vec3((m1 + m2nx * n.
x) * this->x + (m2nx * n.
y - m3 * n.
z) * this->y +
358 (m2nx * n.
z + m3 * n.
y) * this->z,
359 (m2nx * n.
y + m3 * n.
z) * this->x + (m1 + m2 * n.
y * n.
y) * this->y +
360 (m2 * n.
y * n.
z - m3 * n.
x) * this->z,
361 (m2nx * n.
z - m3 * n.
y) * this->x + (m2 * n.
y * n.
z + m3 * n.
x) * this->y +
362 (m1 + m2 * n.
z * n.
z) * this->z);
386 std::vector<vec3> res;
387 BOOST_FOREACH (
vec3 vec, _v)
389 res.push_back(vec * _a);
394 inline std::vector<vec3>
operator+(
const std::vector<vec3>& _u,
const std::vector<vec3>& _v)
396 assert(_u.size() == _v.size());
397 std::vector<vec3> res;
398 for (
unsigned int i = 0; i < _v.size(); ++i)
400 res.push_back(_u[i] + _v[i]);
408 std::vector<dvec3> res;
409 BOOST_FOREACH (
dvec3 vec, _v)
411 res.push_back(vec * _a);
416 inline std::vector<dvec3>
operator+(
const std::vector<dvec3>& _u,
const std::vector<dvec3>& _v)
418 assert(_u.size() == _v.size());
419 std::vector<dvec3> res;
420 for (
unsigned int i = 0; i < _v.size(); ++i)
422 res.push_back(_u[i] + _v[i]);
433 return OPoint3D(
static_cast<double>(_v.
x),
static_cast<double>(_v.
y),
static_cast<double>(_v.
z));
442 return vec3(
static_cast<float>(_p.
_x),
static_cast<float>(_p.
_y),
static_cast<float>(_p.
_z));
451 return OVector3D(
static_cast<double>(_v.
x),
static_cast<double>(_v.
y),
static_cast<double>(_v.
z));
460 return vec3(
static_cast<float>(_v.
_x),
static_cast<float>(_v.
_y),
static_cast<float>(_v.
_z));
490 return !(*
this == _v);
501 return vec2(this->
x * _f, this->
y * _f);
514 return vec2(this->
x + _v.
x, this->y + _v.
y);
518 return vec2(-this->
x, -this->
y);
522 return vec2(this->
x - _v.
x, this->y - _v.
y);
527 return this->
x * _v.
y - this->
y * _v.
x;
532 return *
this = *
this * _f;
536 return *
this = *
this / _f;
540 return *
this = *
this + _v;
544 return *
this = *
this - _v;
549 return this->
x * _v.
x + this->
y * _v.
y;
556 operator const decimal*()
const
576 this->
x = this->
y = 0;
580 return sqrtf(this->
x * this->
x + this->
y * this->
y);
596 return (this->
x * v.
y - this->y *
v.x);
600 return ((this->
x * v.
x) + (this->y *
v.y));
604 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi);
623 return (((vB - vA) * factor) + vA);
629 return v.dot(*
this - vA) /
v.dot(
v);
634 return ((u * (1 - factor)) + (
v * factor));
642 return (
decimal)atan2(
v.y - this->y,
v.x - this->x);
661 return vec2(A, B) ^
vec2(A, C) * 0.5;
666 vout.
x = v1.
y * v2.
z - v1.
z * v2.
y;
667 vout.
y = v1.
z * v2.
x - v1.
x * v2.
z;
668 vout.
z = v1.
x * v2.
y - v1.
y * v2.
x;
672 return vec3(v1.
y * v2.
z - v1.
z * v2.
y, v1.
z * v2.
x - v1.
x * v2.
z, v1.
x * v2.
y - v1.
y * v2.
x);
674 template <
typename base_t>
688 vout.
x = vp1.
x - vp2.
x;
689 vout.
y = vp1.
y - vp2.
y;
690 vout.
z = vp1.
z - vp2.
z;
694 return vec3(vp1.
x - vp2.
x, vp1.
y - vp2.
y, vp1.
z - vp2.
z);
701 return vp1.
x * vp2.
y * vp3.
z + vp1.
y * vp2.
z * vp3.
x + vp1.
z * vp2.
x * vp3.
y - vp1.
x * vp2.
z * vp3.
y -
702 vp1.
y * vp2.
x * vp3.
z - vp1.
z * vp2.
y * vp3.
x;
739 return !(*
this == _v);
752 return vec4(this->
x * _f, this->
y * _f, this->
z * _f, this->
w * _f);
765 return vec4(this->
x + _v.
x, this->y + _v.
y, this->z + _v.
z, this->w + _v.
w);
773 return vec4(this->
x - _v.
x, this->y - _v.
y, this->z - _v.
z, this->w - _v.
w);
778 return *
this = *
this * _f;
782 return *
this = *
this / _f;
786 return *
this = *
this + _v;
790 return *
this = *
this - _v;
795 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z + this->
w;
799 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z + this->
w * _v.
w;
806 operator const decimal*()
const
822 this->
x = this->
y = this->
z = this->
w = 0;
826 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi && fabs(this->
z - _v.
z) < epsi &&
827 fabs(this->
w - _v.
w) < epsi);
861 return -(vp1.
w * (vp2.
x * (vp3.
y * vp4.
z - vp4.
y * vp3.
z) - vp3.
x * (vp2.
y * vp4.
z - vp4.
y * vp2.
z) +
862 vp4.
x * (vp2.
y * vp3.
z - vp3.
y * vp2.
z)) -
863 vp2.
w * (vp1.
x * (vp3.
y * vp4.
z - vp4.
y * vp3.
z) - vp3.
x * (vp1.
y * vp4.
z - vp4.
y * vp1.
z) +
864 vp4.
x * (vp1.
y * vp3.
z - vp3.
y * vp1.
z)) +
865 vp3.
w * (vp1.
x * (vp2.
y * vp4.
z - vp4.
y * vp2.
z) - vp2.
x * (vp1.
y * vp4.
z - vp4.
y * vp1.
z) +
866 vp4.
x * (vp1.
y * vp2.
z - vp2.
y * vp1.
z)) -
867 vp4.
w * (vp1.
x * (vp2.
y * vp3.
z - vp3.
y * vp2.
z) - vp2.
x * (vp1.
y * vp3.
z - vp3.
y * vp1.
z) +
868 vp3.
x * (vp1.
y * vp2.
z - vp2.
y * vp1.
z)));
880 return vp1.
x * (vp2.
y * (vp3.
z - vp4.
z) - vp3.
y * (vp2.
z - vp4.
z) + vp4.
y * (vp2.
z - vp3.
z)) -
881 vp2.
x * (vp1.
y * (vp3.
z - vp4.
z) - vp3.
y * (vp1.
z - vp4.
z) + vp4.
y * (vp1.
z - vp3.
z)) +
882 vp3.
x * (vp1.
y * (vp2.
z - vp4.
z) - vp2.
y * (vp1.
z - vp4.
z) + vp4.
y * (vp1.
z - vp2.
z)) -
883 vp4.
x * (vp1.
y * (vp2.
z - vp3.
z) - vp2.
y * (vp1.
z - vp3.
z) + vp3.
y * (vp1.
z - vp2.
z));
894 return this->x * _v.
x + this->y * _v.
y + this->z * _v.
z + _v.
w;
907 return diff < aproximation;
929 return ((this->
a == iv.
a) && (this->b == iv.
b));
933 return !(*
this == iv);
944 return ivec2(this->
a * _i, this->
b * _i);
948 return ivec2(this->
a / _i, this->
b / _i);
952 return ivec2(this->
a + iv.
a, this->b + iv.
b);
956 return ivec2(-this->
a, -this->
b);
960 return ivec2(this->
a - iv.
a, this->b - iv.
b);
965 return *
this = *
this * _i;
969 return *
this = *
this / _i;
973 return *
this = *
this + iv;
977 return *
this = *
this - iv;
982 return this->
a * iv.
a + this->
b * iv.
b;
989 operator const long*()
const
996 void set(
long _a,
long _b)
1003 this->
a = this->
b = 0;
1047 ivec3(
long _a,
long _b,
long _c) :
a(_a),
b(_b),
c(_c) {}
1048 ivec3(
const long* iv) :
a(iv[0]),
b(iv[1]),
c(iv[2]) {}
1054 return ((this->
a == iv.
a) && (this->b == iv.
b) && (this->c == iv.
c));
1058 return !(*
this == iv);
1070 this->
a = (long)iv[0];
1071 this->
b = (long)iv[1];
1072 this->
c = (long)iv[2];
1077 return ivec3(this->
a * _i, this->
b * _i, this->
c * _i);
1081 return ivec3(this->
a / _i, this->
b / _i, this->
c / _i);
1085 return ivec3(this->
a + iv.
a, this->b + iv.
b, this->c + iv.
c);
1089 return ivec3(-this->
a, -this->
b, -this->
c);
1093 return ivec3(this->
a - iv.
a, this->b - iv.
b, this->c - iv.
c);
1098 return *
this = *
this * _i;
1102 return *
this = *
this / _i;
1106 return *
this = *
this + iv;
1110 return *
this = *
this - iv;
1115 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c;
1123 operator const long*()
const
1130 void set(
long _a,
long _b,
long _c)
1144 this->
a = this->
b = this->
c = 0;
1195 ivec4(
long _a,
long _b,
long _c,
long _d) :
a(_a),
b(_b),
c(_c),
d(_d) {}
1196 ivec4(
const long* iv) :
a(iv[0]),
b(iv[1]),
c(iv[2]),
d(iv[3]) {}
1203 return ((this->
a == iv.
a) && (this->b == iv.
b) && (this->c == iv.
c) && (this->d == iv.
d));
1207 return !(*
this == iv);
1220 return ivec4(this->
a * _i, this->
b * _i, this->
c * _i, this->
d * _i);
1224 return ivec4(this->
a / _i, this->
b / _i, this->
c / _i, this->
d / _i);
1228 return ivec4(this->
a + iv.
a, this->b + iv.
b, this->c + iv.
c, this->d + iv.
d);
1232 return ivec4(-this->
a, -this->
b, -this->
c, -this->
d);
1236 return ivec4(this->
a - iv.
a, this->b - iv.
b, this->c - iv.
c, this->d - iv.
d);
1241 return *
this = *
this * _i;
1245 return *
this = *
this / _i;
1249 return *
this = *
this + iv;
1253 return *
this = *
this - iv;
1258 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + this->
d;
1262 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + this->
d * iv.
d;
1269 operator const long*()
const
1276 void set(
long _a,
long _b,
long _c,
long _d)
1285 this->
a = this->
b = this->
c = this->
d = 0;
1334 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + iv.
d;
1349 vec3 I = (B + C) / 2;
1350 vec3 AG = (I - A) * (2.f / 3.f);
1355 return (A + B + C + D) / 4;
1364 return .5f * ab.
length();
1367 inline float Clamp(
float val,
float low,
float high)
1373 else if (val > high)
1383 inline int Clamp(
int val,
int low,
int high)
1389 else if (val > high)
1401 return (
int)floorf(val);
1516 denom = uu * vv - uv * uv;
1525 numer = uv * vw - vv * uw;
1528 *mua = numer / denom;
1529 *mub = (vw + uv * (*mua)) / vv;
1531 pa->
x = p1.
x + *mua * u.
x;
1532 pa->
y = p1.
y + *mua * u.
y;
1533 pa->
z = p1.
z + *mua * u.
z;
1534 pb->
x = p3.
x + *mub * v.
x;
1535 pb->
y = p3.
y + *mub * v.
y;
1536 pb->
z = p3.
z + *mub * v.
z;
1545 for (i = 0, j = points.size() - 1; i < (
int)points.size(); j = i++)
1547 if ((((points.at(i).y <= p.
y) && (p.
y < points.at(j).y)) ||
1548 ((points.at(j).y <= p.
y) && (p.
y < points.at(i).y))) &&
1550 (points.at(j).x - points.at(i).x) * (p.
y - points.at(i).y) / (points.at(j).y - points.at(i).y) +
1584 vec3 E0 = (vb - va);
1585 vec3 E1 = (vc - va);
1587 vec3 kDiff = (va - P);
1595 decimal fS = fA01 * fB1 - fA11 * fB0;
1596 decimal fT = fA01 * fB0 - fA00 * fB1;
1599 if (fabs(fDet) < 0.00000001f)
1601 return 100000000.0f;
1604 if (fS + fT <= fDet)
1616 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1621 fSqrDist = fB0 * fS + fC;
1632 else if (-fB1 >= fA11)
1635 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1640 fSqrDist = fB1 * fT + fC;
1652 else if (-fB1 >= fA11)
1655 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1660 fSqrDist = fB1 * fT + fC;
1672 else if (-fB0 >= fA00)
1675 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1680 fSqrDist = fB0 * fS + fC;
1689 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1690 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1695 decimal fTmp0, fTmp1, fNumer, fDenom;
1703 fNumer = fTmp1 - fTmp0;
1704 fDenom = fA00 - 2.0f * fA01 + fA11;
1705 if (fNumer >= fDenom)
1709 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1713 fS = fNumer / fDenom;
1715 fSqrDist = fS * (fA00 * fS + fA01 * fT + 2.0f * fB0) +
1716 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1725 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1735 fSqrDist = fB1 * fT + fC;
1745 fNumer = fTmp1 - fTmp0;
1746 fDenom = fA00 - ((
decimal)2.0) * fA01 + fA11;
1747 if (fNumer >= fDenom)
1751 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1755 fT = fNumer / fDenom;
1757 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1758 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1767 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1777 fSqrDist = fB0 * fS + fC;
1783 fNumer = fA11 + fB1 - fA01 - fB0;
1788 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1792 fDenom = fA00 - 2.0f * fA01 + fA11;
1793 if (fNumer >= fDenom)
1797 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1801 fS = fNumer / fDenom;
1803 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1804 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1820 return (
decimal)fabs(fSqrDist);
1833 unsigned int res = 1;
1834 for (
unsigned short i = 0; i < length - 1; i++, res++)
All base classes related to 3D manipulation.
double _y
y coordinate of OCoord3D
double _z
z coordinate of OCoord3D
double _x
x coordinate of OCoord3D
3D vector Vector defined with 3 float numbers
const base_vec3 operator*(base_t _f) const
base_vec3(const base_t &_x, const base_t &_y, const base_t &_z)
base_t length(void) const
const base_vec3 operator/(base_t _f) const
const base_vec3 operator+(const base_vec3 &_v) const
base_vec3 & operator/=(base_t _f)
base_vec3 operator^(const base_vec3 &_v) const
cross product
void set(base_t _x, base_t _y, base_t _z)
decimal distance(const base_vec3 &a_vector) const
Compute the distance between two points pointed by *this and a_vector.
bool compare(const base_vec3 &_v, base_t epsi=EPSILON_6)
base_vec3 & operator=(base_t _f)
base_vec3 lerp(base_vec3 &u, base_vec3 &v, base_t factor)
Linear interpolation function between 2 vectors.
base_vec3(const base_vec3 *_v)
base_vec3(const base_t *_v)
bool barelyEqual(const base_vec3 &_v) const
base_t operator*(const base_vec3 &_v) const
void cross(const base_vec3 &v2)
const base_vec3 operator-(const base_vec3 &_v) const
void cross(const base_vec3 &v1, const base_vec3 &v2)
base_vec3(const base_vec3 &_v)
base_t projectionOnLine(const base_vec3 &vA, const base_vec3 &vB) const
Return the projection factor of *this on the line passing by vA and vB.
base_t angle(const base_vec3 &v) const
Return the angle in radians between *this and v.
bool operator==(const base_vec3 &_v)
base_vec3 operator/(const base_vec3 &_v) const
base_t dot(const base_vec3 &v) const
Scalar product.
base_vec3 & operator+=(const base_vec3 &_v)
base_vec3 & operator*=(base_t _f)
base_vec3 Rotation(const base_vec3 &n, const base_t &angle) const
Vector rotation.
base_t cosinus(const base_vec3 &ac)
base_vec3 & operator-=(const base_vec3 &_v)
base_t & operator[](int _i)
const base_t & operator[](int _i) const
base_vec3(const base_vec3 &_v, const base_vec3 &_w)
ab vector coordinates
base_vec3 closestPointOnSegment(const base_vec3 &vA, const base_vec3 &vB) const
Return the coordinates of the nearest point of *this on the segment [vA,vB].
bool operator!=(const base_vec3 &_v)
const base_vec3 operator-() const
base_vec3 closestPointOnLine(const base_vec3 &vA, const base_vec3 &vB) const
Return the coordinates of the nearest point of *this on the line passing by vA and vB.
2D Vector Vector defined with 2 integers
ivec2 & operator=(long _i)
ivec2 & operator+=(const ivec2 &iv)
const ivec2 operator/(long _i) const
const ivec2 operator+(const ivec2 &iv) const
ivec2 & operator*=(long _i)
long operator*(const ivec2 &iv) const
const ivec2 operator-() const
const ivec2 operator*(long _i) const
void set(long _a, long _b)
ivec2 & operator/=(long _i)
const ivec2 operator-(const ivec2 &iv) const
int operator!=(const ivec2 &iv)
int operator==(const ivec2 &iv)
ivec2 & operator-=(const ivec2 &iv)
3D Vector Vector defined with 3 integers
ivec3 & operator-=(const ivec3 &iv)
ivec3 & operator=(vec3 &iv)
ivec3 & operator+=(const ivec3 &iv)
const ivec3 operator/(long _i) const
const ivec3 operator-() const
ivec3 & operator=(long _i)
ivec3(long _a, long _b, long _c)
const ivec3 operator+(const ivec3 &iv) const
const ivec3 operator*(long _i) const
long operator*(const ivec3 &iv) const
ivec3 & operator/=(long _i)
const ivec3 operator-(const ivec3 &iv) const
ivec3 & operator*=(long _i)
void set(long _a, long _b, long _c)
int operator==(const ivec3 &iv)
int operator!=(const ivec3 &iv)
4D Vector Vector defined with 4 integers
long operator*(const ivec4 &iv) const
int operator!=(const ivec4 &iv)
int operator==(const ivec4 &iv)
const ivec4 operator*(long _i) const
void set(long _a, long _b, long _c, long _d)
ivec4(long _a, long _b, long _c, long _d)
ivec4 & operator=(long _i)
long operator*(const ivec3 &iv) const
const ivec4 operator-() const
const ivec4 operator/(long _i) const
const ivec4 operator-(const ivec4 &iv) const
ivec4 & operator/=(long _i)
ivec4 & operator+=(const ivec4 &iv)
ivec4 & operator-=(const ivec4 &iv)
ivec4(const ivec3 &iv, long _d)
const ivec4 operator+(const ivec4 &iv) const
ivec4 & operator*=(long _i)
2D Vector Vector defined with 2 float numbers
vec2(decimal _x, decimal _y)
int operator==(const vec2 &_v)
void set(decimal _x, decimal _y)
vec2 & operator*=(decimal _f)
vec2 & operator=(decimal _f)
const vec2 operator-(const vec2 &_v) const
vec2 & operator-=(const vec2 &_v)
int operator!=(const vec2 &_v)
const vec2 operator/(decimal _f) const
decimal length(void) const
vec2 & operator/=(decimal _f)
decimal det(vec2 &v)
2D determinant
const vec2 operator+(const vec2 &_v) const
vec2 lerp(vec2 &u, vec2 &v, decimal factor)
Linear interpolation function between 2 vectors.
decimal dot(const vec2 &v)
Scalar product.
decimal & operator[](int _i)
vec2(const vec2 &_v, const vec2 &_w)
bool compare(const vec2 &_v, decimal epsi=EPSILON_6)
decimal operator^(const vec2 &_v) const
vec2 closestPointOnSegment(const vec2 &vA, const vec2 &vB)
Return the coordinates of the nearest point of *this on the segment vA,vB.
const vec2 operator*(decimal _f) const
decimal operator*(const vec2 &_v) const
decimal angle(const vec2 &v)
vec2 closestPointOnLine(const vec2 &vA, const vec2 &vB)
Return the coordinates of the nearest point of *this on the line passing by vA and vB.
decimal projectionOnLine(const vec2 &vA, const vec2 &vB)
Return the projection factor of *this on the line passing by vA and vB.
const vec2 operator-() const
const decimal & operator[](int _i) const
vec2 & operator+=(const vec2 &_v)
4D Vector Vector defined with 4 float numbers
const vec4 operator*(decimal _f) const
vec4 & operator*=(decimal _f)
bool compare(const vec4 &_v, decimal epsi=EPSILON_6)
const vec4 operator/(decimal _f) const
vec4 & operator/=(decimal _f)
vec4(decimal _x, decimal _y, decimal _z, decimal _w)
decimal operator*(const vec4 &_v) const
const vec4 operator+(const vec4 &_v) const
vec4 & operator+=(const vec4 &_v)
const vec4 operator-(const vec4 &_v) const
decimal operator*(const vec3 &_v) const
const vec4 operator-() const
vec4(const vec3 &_v, decimal _w)
void set(decimal _x, decimal _y, decimal _z, decimal _w)
vec4 & operator=(decimal _f)
int operator==(const vec4 &_v)
vec4 & operator-=(const vec4 &_v)
int operator!=(const vec4 &_v)
unsigned int buildComplementaryBitSet(const unsigned int &length, const unsigned int &bitSet)
bool LineLineIntersect(const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4, vec3 *pa, vec3 *pb, decimal *mua, decimal *mub)
Calculate the segment between the lines (p1,p2) and (p3,p4)
void Cross(const vec3 &v1, const vec3 &v2, vec3 &vout)
unsigned int buildBitSet(const unsigned short &length)
vec3 GetGTriangle(const vec3 &A, const vec3 &B, const vec3 &C)
decimal GetAireTriangle(const vec3 &a, const vec3 &b, const vec3 &c)
base_vec3< double > dvec3
bool colinear(const vec3 &A, const vec3 &B, const vec3 &C, const decimal &aproximation)
vec3 GetGTetra(const vec3 &A, const vec3 &B, const vec3 &C, const vec3 &D)
std::vector< vec3 > operator+(const std::vector< vec3 > &_u, const std::vector< vec3 > &_v)
decimal ClosestDistanceBetweenDotAndTriangle(const vec3 &va, const vec3 &vb, const vec3 &vc, const vec3 &P, decimal *pfSParam, decimal *pfTParam)
float Clamp(float val, float low, float high)
void Vector(const vec3 &vp1, const vec3 &vp2, vec3 &vout)
vec3 OPoint3Dtovec3(const OPoint3D &_p)
Converts a OPoint3D to vec3.
OPoint3D vec3toOPoint3D(const vec3 &_v)
Converts a vec3 to OPoint3D.
decimal Determinant(const vec3 &vp1, const vec3 &vp2, const vec3 &vp3)
std::vector< vec3 > operator*(const std::vector< vec3 > &_v, const decimal &_a)
decimal CalcTetraVolume(vec3 A, vec3 B, vec3 C, vec3 D)
vec3 Vector_r(const vec3 &vp1, const vec3 &vp2)
vec3 FaceNormal(const vec3 &vp1, const vec3 &vp2, const vec3 &vp3)
vec3 Cross_r(const vec3 &v1, const vec3 &v2)
OVector3D vec3toOVector3D(const vec3 &_v)
Converts a vec3 to OVector3D.
bool pointInPolygone(const vec2 &p, const std::vector< vec2 > &points)
base_vec3< decimal > vec3
decimal area(const vec2 &A, const vec2 &B, const vec2 &C)
vec3 OVector3Dtovec3(const OVector3D &_v)
Converts a OVector3D to vec3.