Merge pull request #11085 from AdmiralCurtiss/tvec-equality
Add TVec and RawValue equality operators.
This commit is contained in:
commit
c297474d87
|
@ -24,6 +24,11 @@ union TVec3
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(const TVec3& other) const
|
||||||
|
{
|
||||||
|
return x == other.x && y == other.y && z == other.z;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr TVec3 Cross(const TVec3& rhs) const
|
constexpr TVec3 Cross(const TVec3& rhs) const
|
||||||
{
|
{
|
||||||
return {(y * rhs.z) - (rhs.y * z), (z * rhs.x) - (rhs.z * x), (x * rhs.y) - (rhs.x * y)};
|
return {(y * rhs.z) - (rhs.y * z), (z * rhs.x) - (rhs.z * x), (x * rhs.y) - (rhs.x * y)};
|
||||||
|
@ -153,6 +158,11 @@ union TVec4
|
||||||
constexpr TVec4(TVec3<T> _vec, T _w) : TVec4{_vec.x, _vec.y, _vec.z, _w} {}
|
constexpr TVec4(TVec3<T> _vec, T _w) : TVec4{_vec.x, _vec.y, _vec.z, _w} {}
|
||||||
constexpr TVec4(T _x, T _y, T _z, T _w) : data{_x, _y, _z, _w} {}
|
constexpr TVec4(T _x, T _y, T _z, T _w) : data{_x, _y, _z, _w} {}
|
||||||
|
|
||||||
|
constexpr bool operator==(const TVec4& other) const
|
||||||
|
{
|
||||||
|
return x == other.x && y == other.y && z == other.z && w == other.w;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr T Dot(const TVec4& other) const
|
constexpr T Dot(const TVec4& other) const
|
||||||
{
|
{
|
||||||
return x * other.x + y * other.y + z * other.z + w * other.w;
|
return x * other.x + y * other.y + z * other.z + w * other.w;
|
||||||
|
@ -216,6 +226,8 @@ union TVec2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(const TVec2& other) const { return x == other.x && y == other.y; }
|
||||||
|
|
||||||
constexpr T Cross(const TVec2& rhs) const { return (x * rhs.y) - (y * rhs.x); }
|
constexpr T Cross(const TVec2& rhs) const { return (x * rhs.y) - (y * rhs.x); }
|
||||||
constexpr T Dot(const TVec2& rhs) const { return (x * rhs.x) + (y * rhs.y); }
|
constexpr T Dot(const TVec2& rhs) const { return (x * rhs.x) + (y * rhs.y); }
|
||||||
constexpr T LengthSquared() const { return Dot(*this); }
|
constexpr T LengthSquared() const { return Dot(*this); }
|
||||||
|
|
|
@ -103,13 +103,15 @@ struct ThreePointCalibration
|
||||||
template <typename T, size_t Bits>
|
template <typename T, size_t Bits>
|
||||||
struct RawValue
|
struct RawValue
|
||||||
{
|
{
|
||||||
RawValue() = default;
|
constexpr RawValue() = default;
|
||||||
explicit RawValue(const T& value_) : value{value_} {}
|
constexpr explicit RawValue(const T& value_) : value{value_} {}
|
||||||
|
|
||||||
static constexpr size_t BITS_OF_PRECISION = Bits;
|
static constexpr size_t BITS_OF_PRECISION = Bits;
|
||||||
|
|
||||||
T value;
|
T value;
|
||||||
|
|
||||||
|
constexpr bool operator==(const RawValue& other) const = default;
|
||||||
|
|
||||||
template <typename OtherT, size_t OtherBits>
|
template <typename OtherT, size_t OtherBits>
|
||||||
auto GetNormalizedValue(const TwoPointCalibration<OtherT, OtherBits>& calibration) const
|
auto GetNormalizedValue(const TwoPointCalibration<OtherT, OtherBits>& calibration) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue