51 std::enable_if_t<std::is_integral_v<Value_type> &&
111 explicit operator pointer() noexcept {
return &
x; }
125 return x == rhs.x &&
y == rhs.y;
133 {
x=vx;
y=vy;
return *
this; }
137 {
x=xy[0];
y=xy[1];
return *
this; }
141 {
x+=dx;
y+=dy;
return *
this; }
145 {
x*=sx;
y*=sy;
return *
this; }
149 {
x*=s;
y*=s;
return *
this; }
196 std::string
toString() const noexcept {
return std::to_string(
x)+
", "+std::to_string(
y); }
233 return x == o.
x &&
y == o.
y;
238 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
250 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
256 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
264 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
270 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
276 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
282 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
284 return Vector2I<T>(std::min(lhs.x, rhs.x), std::min(lhs.y, rhs.y));
288 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
290 return Vector2I<T>(std::max(lhs.x, rhs.x), std::max(lhs.y, rhs.y));
294 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
296 return out << v.toString();
302 static_assert(
sizeof(int) ==
alignof(
Vec2i));
304 static_assert(
sizeof(int)*2 ==
sizeof(
Vec2i));
310 std::enable_if_t<std::numeric_limits<Value_type>::is_integer &&
317 static_assert(
sizeof(int) ==
alignof(
Point2i));
319 static_assert(
sizeof(int)*2 ==
sizeof(
Point2i));
2D vector using two value_type components.
constexpr Vector2I & operator-=(const Vector2I &rhs) noexcept
this = this - rhs, returns this.
constexpr Vector2I(const Vector2I &o) noexcept=default
static constexpr const value_type zero
constexpr Vector2I(Vector2I &&o) noexcept=default
constexpr iterator get(iterator xy) const noexcept
xy = this, returns xy.
const value_type * const_pointer
constexpr Vector2I() noexcept
constexpr value_type length_sq() const noexcept
Return the squared length of this vector, a.k.a the squared norm or squared magnitude
constexpr Vector2I & operator+=(const Vector2I &rhs) noexcept
this = this + rhs, returns this.
constexpr const_iterator cbegin() const noexcept
constexpr bool is_zero() const noexcept
constexpr Vector2I & scale(const value_type s) noexcept
this = this * s, returns this.
constexpr Vector2I(const value_type x_, const value_type y_) noexcept
constexpr Vector2I & set(const value_type vx, const value_type vy) noexcept
TODO constexpr bool operator<=>(const vec2i_t& rhs ) const noexcept { return ... }...
constexpr Vector2I & operator=(Vector2I &&) noexcept=default
constexpr value_type length() const noexcept
Return the length of this vector, a.k.a the norm or magnitude
static constexpr int value_alignment
jau::float_bytes< sizeof(value_type)>::type float_type
bool intersects(const Vector2I &o)
static constexpr const size_t byte_size
std::string toString() const noexcept
constexpr value_type operator[](size_t i) const noexcept
Returns read-only component.
void rotate(const float_type sin, const float_type cos, const Vector2I &ctr)
constexpr Vector2I & operator*=(const value_type s) noexcept
Scale this vector with given scale factor.
constexpr bool operator==(const Vector2I &rhs) const noexcept
constexpr_cxx26 void rotate(const float_type radians, const Vector2I &ctr)
constexpr Vector2I & operator=(const Vector2I &) noexcept=default
constexpr Vector2I & set(const_iterator xy) noexcept
this = xy, returns this.
constexpr Vector2I & add(const value_type dx, const value_type dy) noexcept
this = this + {sx, sy}, returns this.
constexpr Vector2I(const value_type v) noexcept
constexpr iterator begin() noexcept
constexpr Vector2I & mul(const value_type sx, const value_type sy) noexcept
this = this * {sx, sy}, returns this.
constexpr Vector2I copy() noexcept
const value_type & const_reference
constexpr Vector2I & normalize() noexcept
Normalize this vector in place, returns *this.
static constexpr const value_type one
constexpr Vector2I & operator/=(const value_type s) noexcept
Divide this vector with given scale factor.
static constexpr const size_t components
constexpr reference operator[](size_t i) noexcept
Returns writeable reference to component.
const value_type * const_iterator
std::enable_if_t< std::is_floating_point_v< T >, bool > constexpr is_zero(const T &a, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
Returns true if the given value is less than epsilon, w/ epsilon > 0.
constexpr jau::sint_bytes_t< sizeof(T)> round_to_int(const T v) noexcept
Returns the rounded value cast to int.
constexpr Quaternion< T > operator-(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
constexpr Vector2F< T > operator/(const Vector2F< T > &lhs, const T s) noexcept
constexpr Vector2F< T > max(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
constexpr Vector2F< T > min(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
constexpr Quaternion< T > operator+(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept
Vector2I< Value_type > Point2I
Point2I alias of Vector2I.