17#ifndef GZ_MATH_VECTOR4_HH_
18#define GZ_MATH_VECTOR4_HH_
26#include <gz/math/config.hh>
31 inline namespace GZ_MATH_VERSION_NAMESPACE {
69 return static_cast<T
>(sqrt(
70 (this->data[0]-
_pt[0])*(this->data[0]-
_pt[0]) +
71 (this->data[1]-
_pt[1])*(this->data[1]-
_pt[1]) +
72 (this->data[2]-
_pt[2])*(this->data[2]-
_pt[2]) +
73 (this->data[3]-
_pt[3])*(this->data[3]-
_pt[3])));
91 return static_cast<T
>(sqrt(this->SquaredLength()));
99 this->data[0] * this->data[0] +
100 this->data[1] * this->data[1] +
101 this->data[2] * this->data[2] +
102 this->data[3] * this->data[3];
141 T d = this->Length();
143 if (!
equal<T>(d,
static_cast<T
>(0.0)))
166 return this->data[0] *
_v[0] +
167 this->data[1] *
_v[1] +
168 this->data[2] *
_v[2] +
169 this->data[3] *
_v[3];
182 return std::abs(this->data[0] *
_v[0]) +
183 std::abs(this->data[1] *
_v[1]) +
184 std::abs(this->data[2] *
_v[2]) +
185 std::abs(this->data[3] *
_v[3]);
192 return Vector4(std::abs(this->data[0]),
193 std::abs(this->data[1]),
194 std::abs(this->data[2]),
195 std::abs(this->data[3]));
216 this->data[0] =
std::max(
_v[0], this->data[0]);
217 this->data[1] =
std::max(
_v[1], this->data[1]);
218 this->data[2] =
std::max(
_v[2], this->data[2]);
219 this->data[3] =
std::max(
_v[3], this->data[3]);
227 this->data[0] =
std::min(
_v[0], this->data[0]);
228 this->data[1] =
std::min(
_v[1], this->data[1]);
229 this->data[2] =
std::min(
_v[2], this->data[2]);
230 this->data[3] =
std::min(
_v[3], this->data[3]);
251 return this->data[0] + this->data[1] + this->data[2] + this->data[3];
272 this->data[1] +
_v[1],
273 this->data[2] +
_v[2],
274 this->data[3] +
_v[3]);
282 this->data[0] +=
_v[0];
283 this->data[1] +=
_v[1];
284 this->data[2] +=
_v[2];
285 this->data[3] +=
_v[3];
328 return Vector4(-this->data[0], -this->data[1],
329 -this->data[2], -this->data[3]);
338 this->data[1] -
_v[1],
339 this->data[2] -
_v[2],
340 this->data[3] -
_v[3]);
348 this->data[0] -=
_v[0];
349 this->data[1] -=
_v[1];
350 this->data[2] -=
_v[2];
351 this->data[3] -=
_v[3];
398 this->data[1] /
_v[1],
399 this->data[2] /
_v[2],
400 this->data[3] /
_v[3]);
410 this->data[0] /=
_v[0];
411 this->data[1] /=
_v[1];
412 this->data[2] /=
_v[2];
413 this->data[3] /=
_v[3];
426 this->data[2] /
_v, this->data[3] /
_v);
450 this->data[1] *
_pt[1],
451 this->data[2] *
_pt[2],
452 this->data[3] *
_pt[3]);
461 this->data[0]*
_m(0, 0) + this->data[1]*
_m(1, 0) +
462 this->data[2]*
_m(2, 0) + this->data[3]*
_m(3, 0),
463 this->data[0]*
_m(0, 1) + this->data[1]*
_m(1, 1) +
464 this->data[2]*
_m(2, 1) + this->data[3]*
_m(3, 1),
465 this->data[0]*
_m(0, 2) + this->data[1]*
_m(1, 2) +
466 this->data[2]*
_m(2, 2) + this->data[3]*
_m(3, 2),
467 this->data[0]*
_m(0, 3) + this->data[1]*
_m(1, 3) +
468 this->data[2]*
_m(2, 3) + this->data[3]*
_m(3, 3));
478 this->data[0] *=
_pt[0];
479 this->data[1] *=
_pt[1];
480 this->data[2] *=
_pt[2];
481 this->data[3] *=
_pt[3];
492 this->data[2] *
_v, this->data[3] *
_v);
537 return this->Equal(
_v,
static_cast<T
>(1
e-6));
546 return !(*
this ==
_pt);
567 return this->data[
clamp(
_index, GZ_ZERO_SIZE_T, GZ_THREE_SIZE_T)];
576 return this->data[
clamp(
_index, GZ_ZERO_SIZE_T, GZ_THREE_SIZE_T)];
583 return this->data[0];
590 return this->data[1];
597 return this->data[2];
604 return this->data[3];
611 return this->data[0];
618 return this->data[1];
625 return this->data[2];
632 return this->data[3];
637 public:
inline void X(
const T &
_v)
644 public:
inline void Y(
const T &
_v)
651 public:
inline void Z(
const T &
_v)
658 public:
inline void W(
const T &
_v)
669 return this->data[0] <
_pt[0] || this->data[1] <
_pt[1] ||
670 this->data[2] <
_pt[2] || this->data[3] <
_pt[3];
680 for (
auto i : {0, 1, 2, 3})
700 _in.setf(std::ios_base::skipws);
716 constexpr Vector4<T> gVector4Zero(0, 0, 0, 0);
719 constexpr Vector4<T> gVector4One(1, 1, 1, 1);
722 constexpr Vector4<T> gVector4NaN(