24 #include <boost/foreach.hpp>
50 #define EPSILON_4 (decimal)0.0001
60 (decimal)0.000000000000001
66 (decimal)0.0000000000000000000001
71 #define M_PI (decimal)3.141592653589793238462643383279
74 #define M_PIDIV2 (decimal)1.570796326794896619231321691639
77 #define M_2PI (decimal)6.283185307179586476925286766559
81 #define M_4PI (decimal)12.566370614359172953850573533118
84 #define M_PI2 (decimal)9.869604401089358618834490999876
85 #define M_PIDIV180 (decimal)0.01745329251994329576923690768488
86 #define M_180DIVPI (decimal)57.295779513082320876798154814105
88 #define DegToRad(a) a *= M_PIDIV180
89 #define RadToDeg(a) a *= M_180DIVPI
90 #define RADIANS(a) a* M_PIDIV180
91 #define DEGRES(a) a* M_180DIVPI
92 #define ABS(x) (fabs(x))
95 #define SIGN(x) ((x) > 0 ? 1 : -1)
117 base_vec3(
const base_t& _x,
const base_t& _y,
const base_t& _z) :
x(_x),
y(_y),
z(_z) {}
123 :
x(_w.
x - _v.
x),
y(_w.
y - _v.
y),
z(_w.
z - _v.
z) {}
146 return !(*
this == _v);
158 return base_vec3(this->
x * _f, this->
y * _f, this->
z * _f);
175 return base_vec3(this->
x + _v.
x, this->y + _v.
y, this->z + _v.
z);
183 return base_vec3(this->
x - _v.
x, this->y - _v.
y, this->z - _v.
z);
188 return *
this = *
this * _f;
192 return *
this = *
this / _f;
196 return *
this = *
this + _v;
200 return *
this = *
this - _v;
205 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z;
209 return base_vec3(this->
y * _v.
z - this->z * _v.
y, this->z * _v.
x - this->x * _v.
z,
210 this->x * _v.
y - this->y * _v.
x);
219 operator const base_t*()
const
234 return (fabs(this->
x - _v.
x) < 0.5 && fabs(this->
y - _v.
y) < 0.5 && fabs(this->
z - _v.
z) < 0.5);
236 void set(base_t _x, base_t _y, base_t _z)
244 this->
x = this->
y = this->
z = 0;
248 return sqrtf(this->
x * this->
x + this->
y * this->
y + this->
z * this->
z);
252 base_t inv, l = this->
length();
265 this->
x = v1.
y * v2.
z - v1.
z * v2.
y;
266 this->
y = v1.
z * v2.
x - v1.
x * v2.
z;
267 this->
z = v1.
x * v2.
y - v1.
y * v2.
x;
271 base_t
x = this->
y * v2.
z - this->
z * v2.
y;
272 base_t
y = this->
z * v2.
x - this->x * v2.
z;
273 this->
z = this->x * v2.
y - this->y * v2.
x;
279 return (this->
x * ac.
x + this->y * ac.
y + this->z * ac.
z) / (
length() * ac.
length());
283 return ((this->
x * v.
x) + (this->y *
v.y) + (this->z *
v.z));
288 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi && fabs(this->
z - _v.
z) < epsi);
317 return (((vB - vA) * factor) + vA);
323 return v.dot(*
this - vA) /
v.dot(
v);
328 return ((u * (1 - factor)) + (
v * factor));
344 return (sqrt(dx * dx + dy * dy + dz * dz));
357 base_t m1 = cos(
angle);
359 base_t m3 = sin(
angle);
361 base_t m2nx = m2 * n.
x;
363 return base_vec3((m1 + m2nx * n.
x) * this->x + (m2nx * n.
y - m3 * n.
z) * this->y +
364 (m2nx * n.
z + m3 * n.
y) * this->z,
365 (m2nx * n.
y + m3 * n.
z) * this->x + (m1 + m2 * n.
y * n.
y) * this->y +
366 (m2 * n.
y * n.
z - m3 * n.
x) * this->z,
367 (m2nx * n.
z - m3 * n.
y) * this->x + (m2 * n.
y * n.
z + m3 * n.
x) * this->y +
368 (m1 + m2 * n.
z * n.
z) * this->z);
392 std::vector<vec3> res;
393 BOOST_FOREACH (
vec3 vec, _v)
395 res.push_back(vec * _a);
400 inline std::vector<vec3>
operator+(
const std::vector<vec3>& _u,
const std::vector<vec3>& _v)
402 assert(_u.size() == _v.size());
403 std::vector<vec3> res;
404 for (
unsigned int i = 0; i < _v.size(); ++i)
406 res.push_back(_u[i] + _v[i]);
414 std::vector<dvec3> res;
415 BOOST_FOREACH (
dvec3 vec, _v)
417 res.push_back(vec * _a);
422 inline std::vector<dvec3>
operator+(
const std::vector<dvec3>& _u,
const std::vector<dvec3>& _v)
424 assert(_u.size() == _v.size());
425 std::vector<dvec3> res;
426 for (
unsigned int i = 0; i < _v.size(); ++i)
428 res.push_back(_u[i] + _v[i]);
439 return OPoint3D(
static_cast<double>(_v.
x),
static_cast<double>(_v.
y),
static_cast<double>(_v.
z));
448 return vec3(
static_cast<float>(_p.
_x),
static_cast<float>(_p.
_y),
static_cast<float>(_p.
_z));
457 return OVector3D(
static_cast<double>(_v.
x),
static_cast<double>(_v.
y),
static_cast<double>(_v.
z));
466 return vec3(
static_cast<float>(_v.
_x),
static_cast<float>(_v.
_y),
static_cast<float>(_v.
_z));
496 return !(*
this == _v);
507 return vec2(this->
x * _f, this->
y * _f);
520 return vec2(this->
x + _v.
x, this->y + _v.
y);
524 return vec2(-this->
x, -this->
y);
528 return vec2(this->
x - _v.
x, this->y - _v.
y);
533 return this->
x * _v.
y - this->
y * _v.
x;
538 return *
this = *
this * _f;
542 return *
this = *
this / _f;
546 return *
this = *
this + _v;
550 return *
this = *
this - _v;
555 return this->
x * _v.
x + this->
y * _v.
y;
562 operator const decimal*()
const
582 this->
x = this->
y = 0;
586 return sqrtf(this->
x * this->
x + this->
y * this->
y);
602 return (this->
x * v.
y - this->y *
v.x);
606 return ((this->
x * v.
x) + (this->y *
v.y));
610 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi);
629 return (((vB - vA) * factor) + vA);
635 return v.dot(*
this - vA) /
v.dot(
v);
640 return ((u * (1 - factor)) + (
v * factor));
648 return (
decimal)atan2(
v.y - this->y,
v.x - this->x);
667 return vec2(A, B) ^
vec2(A, C) * 0.5;
672 vout.
x = v1.
y * v2.
z - v1.
z * v2.
y;
673 vout.
y = v1.
z * v2.
x - v1.
x * v2.
z;
674 vout.
z = v1.
x * v2.
y - v1.
y * v2.
x;
678 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);
680 template <
typename base_t>
694 vout.
x = vp1.
x - vp2.
x;
695 vout.
y = vp1.
y - vp2.
y;
696 vout.
z = vp1.
z - vp2.
z;
700 return vec3(vp1.
x - vp2.
x, vp1.
y - vp2.
y, vp1.
z - vp2.
z);
707 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 -
708 vp1.
y * vp2.
x * vp3.
z - vp1.
z * vp2.
y * vp3.
x;
745 return !(*
this == _v);
758 return vec4(this->
x * _f, this->
y * _f, this->
z * _f, this->
w * _f);
771 return vec4(this->
x + _v.
x, this->y + _v.
y, this->z + _v.
z, this->w + _v.
w);
779 return vec4(this->
x - _v.
x, this->y - _v.
y, this->z - _v.
z, this->w - _v.
w);
784 return *
this = *
this * _f;
788 return *
this = *
this / _f;
792 return *
this = *
this + _v;
796 return *
this = *
this - _v;
801 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z + this->
w;
805 return this->
x * _v.
x + this->
y * _v.
y + this->
z * _v.
z + this->
w * _v.
w;
812 operator const decimal*()
const
828 this->
x = this->
y = this->
z = this->
w = 0;
832 return (fabs(this->
x - _v.
x) < epsi && fabs(this->
y - _v.
y) < epsi && fabs(this->
z - _v.
z) < epsi &&
833 fabs(this->
w - _v.
w) < epsi);
867 return -(vp1.
w * (vp2.
x * (vp3.
y * vp4.
z - vp4.
y * vp3.
z) - vp3.
x * (vp2.
y * vp4.
z - vp4.
y * vp2.
z) +
868 vp4.
x * (vp2.
y * vp3.
z - vp3.
y * vp2.
z)) -
869 vp2.
w * (vp1.
x * (vp3.
y * vp4.
z - vp4.
y * vp3.
z) - vp3.
x * (vp1.
y * vp4.
z - vp4.
y * vp1.
z) +
870 vp4.
x * (vp1.
y * vp3.
z - vp3.
y * vp1.
z)) +
871 vp3.
w * (vp1.
x * (vp2.
y * vp4.
z - vp4.
y * vp2.
z) - vp2.
x * (vp1.
y * vp4.
z - vp4.
y * vp1.
z) +
872 vp4.
x * (vp1.
y * vp2.
z - vp2.
y * vp1.
z)) -
873 vp4.
w * (vp1.
x * (vp2.
y * vp3.
z - vp3.
y * vp2.
z) - vp2.
x * (vp1.
y * vp3.
z - vp3.
y * vp1.
z) +
874 vp3.
x * (vp1.
y * vp2.
z - vp2.
y * vp1.
z)));
886 return vp1.
x * (vp2.
y * (vp3.
z - vp4.
z) - vp3.
y * (vp2.
z - vp4.
z) + vp4.
y * (vp2.
z - vp3.
z)) -
887 vp2.
x * (vp1.
y * (vp3.
z - vp4.
z) - vp3.
y * (vp1.
z - vp4.
z) + vp4.
y * (vp1.
z - vp3.
z)) +
888 vp3.
x * (vp1.
y * (vp2.
z - vp4.
z) - vp2.
y * (vp1.
z - vp4.
z) + vp4.
y * (vp1.
z - vp2.
z)) -
889 vp4.
x * (vp1.
y * (vp2.
z - vp3.
z) - vp2.
y * (vp1.
z - vp3.
z) + vp3.
y * (vp1.
z - vp2.
z));
900 return this->x * _v.
x + this->y * _v.
y + this->z * _v.
z + _v.
w;
913 return diff < aproximation;
935 return ((this->
a == iv.
a) && (this->b == iv.
b));
939 return !(*
this == iv);
950 return ivec2(this->
a * _i, this->
b * _i);
954 return ivec2(this->
a / _i, this->
b / _i);
958 return ivec2(this->
a + iv.
a, this->b + iv.
b);
962 return ivec2(-this->
a, -this->
b);
966 return ivec2(this->
a - iv.
a, this->b - iv.
b);
971 return *
this = *
this * _i;
975 return *
this = *
this / _i;
979 return *
this = *
this + iv;
983 return *
this = *
this - iv;
988 return this->
a * iv.
a + this->
b * iv.
b;
995 operator const long*()
const
1009 this->
a = this->
b = 0;
1053 ivec3(
long _a,
long _b,
long _c) :
a(_a),
b(_b),
c(_c) {}
1054 ivec3(
const long* iv) :
a(iv[0]),
b(iv[1]),
c(iv[2]) {}
1060 return ((this->
a == iv.
a) && (this->b == iv.
b) && (this->c == iv.
c));
1064 return !(*
this == iv);
1076 this->
a = (long)iv[0];
1077 this->
b = (long)iv[1];
1078 this->
c = (long)iv[2];
1083 return ivec3(this->
a * _i, this->
b * _i, this->
c * _i);
1087 return ivec3(this->
a / _i, this->
b / _i, this->
c / _i);
1091 return ivec3(this->
a + iv.
a, this->b + iv.
b, this->c + iv.
c);
1095 return ivec3(-this->
a, -this->
b, -this->
c);
1099 return ivec3(this->
a - iv.
a, this->b - iv.
b, this->c - iv.
c);
1104 return *
this = *
this * _i;
1108 return *
this = *
this / _i;
1112 return *
this = *
this + iv;
1116 return *
this = *
this - iv;
1121 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c;
1129 operator const long*()
const
1136 void set(
long _a,
long _b,
long _c)
1150 this->
a = this->
b = this->
c = 0;
1201 ivec4(
long _a,
long _b,
long _c,
long _d) :
a(_a),
b(_b),
c(_c),
d(_d) {}
1202 ivec4(
const long* iv) :
a(iv[0]),
b(iv[1]),
c(iv[2]),
d(iv[3]) {}
1209 return ((this->
a == iv.
a) && (this->b == iv.
b) && (this->c == iv.
c) && (this->d == iv.
d));
1213 return !(*
this == iv);
1226 return ivec4(this->
a * _i, this->
b * _i, this->
c * _i, this->
d * _i);
1230 return ivec4(this->
a / _i, this->
b / _i, this->
c / _i, this->
d / _i);
1234 return ivec4(this->
a + iv.
a, this->b + iv.
b, this->c + iv.
c, this->d + iv.
d);
1238 return ivec4(-this->
a, -this->
b, -this->
c, -this->
d);
1242 return ivec4(this->
a - iv.
a, this->b - iv.
b, this->c - iv.
c, this->d - iv.
d);
1247 return *
this = *
this * _i;
1251 return *
this = *
this / _i;
1255 return *
this = *
this + iv;
1259 return *
this = *
this - iv;
1264 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + this->
d;
1268 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + this->
d * iv.
d;
1275 operator const long*()
const
1282 void set(
long _a,
long _b,
long _c,
long _d)
1291 this->
a = this->
b = this->
c = this->
d = 0;
1340 return this->
a * iv.
a + this->
b * iv.
b + this->
c * iv.
c + iv.
d;
1355 vec3 I = (B + C) / 2;
1356 vec3 AG = (I - A) * (2.f / 3.f);
1361 return (A + B + C + D) / 4;
1370 return .5f * ab.
length();
1373 inline float Clamp(
float val,
float low,
float high)
1379 else if (val > high)
1389 inline int Clamp(
int val,
int low,
int high)
1395 else if (val > high)
1407 return (
int)floorf(val);
1522 denom = uu * vv - uv * uv;
1531 numer = uv * vw - vv * uw;
1534 *mua = numer / denom;
1535 *mub = (vw + uv * (*mua)) / vv;
1537 pa->
x = p1.
x + *mua * u.
x;
1538 pa->
y = p1.
y + *mua * u.
y;
1539 pa->
z = p1.
z + *mua * u.
z;
1540 pb->
x = p3.
x + *mub * v.
x;
1541 pb->
y = p3.
y + *mub * v.
y;
1542 pb->
z = p3.
z + *mub * v.
z;
1551 for (i = 0, j = points.size() - 1; i < (
int)points.size(); j = i++)
1553 if ((((points.at(i).y <= p.
y) && (p.
y < points.at(j).y)) ||
1554 ((points.at(j).y <= p.
y) && (p.
y < points.at(i).y))) &&
1556 (points.at(j).x - points.at(i).x) * (p.
y - points.at(i).y) / (points.at(j).y - points.at(i).y) +
1590 vec3 E0 = (vb - va);
1591 vec3 E1 = (vc - va);
1593 vec3 kDiff = (va - P);
1601 decimal fS = fA01 * fB1 - fA11 * fB0;
1602 decimal fT = fA01 * fB0 - fA00 * fB1;
1605 if (fabs(fDet) < 0.00000001f)
1607 return 100000000.0f;
1610 if (fS + fT <= fDet)
1622 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1627 fSqrDist = fB0 * fS + fC;
1638 else if (-fB1 >= fA11)
1641 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1646 fSqrDist = fB1 * fT + fC;
1658 else if (-fB1 >= fA11)
1661 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1666 fSqrDist = fB1 * fT + fC;
1678 else if (-fB0 >= fA00)
1681 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1686 fSqrDist = fB0 * fS + fC;
1695 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1696 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1701 decimal fTmp0, fTmp1, fNumer, fDenom;
1709 fNumer = fTmp1 - fTmp0;
1710 fDenom = fA00 - 2.0f * fA01 + fA11;
1711 if (fNumer >= fDenom)
1715 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1719 fS = fNumer / fDenom;
1721 fSqrDist = fS * (fA00 * fS + fA01 * fT + 2.0f * fB0) +
1722 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1731 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1741 fSqrDist = fB1 * fT + fC;
1751 fNumer = fTmp1 - fTmp0;
1752 fDenom = fA00 - ((
decimal)2.0) * fA01 + fA11;
1753 if (fNumer >= fDenom)
1757 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1761 fT = fNumer / fDenom;
1763 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1764 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1773 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1783 fSqrDist = fB0 * fS + fC;
1789 fNumer = fA11 + fB1 - fA01 - fB0;
1794 fSqrDist = fA11 + ((
decimal)2.0) * fB1 + fC;
1798 fDenom = fA00 - 2.0f * fA01 + fA11;
1799 if (fNumer >= fDenom)
1803 fSqrDist = fA00 + ((
decimal)2.0) * fB0 + fC;
1807 fS = fNumer / fDenom;
1809 fSqrDist = fS * (fA00 * fS + fA01 * fT + ((
decimal)2.0) * fB0) +
1810 fT * (fA01 * fS + fA11 * fT + ((
decimal)2.0) * fB1) + fC;
1826 return (
decimal)fabs(fSqrDist);
1839 unsigned int res = 1;
1840 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.