48 std::enable_if_t<std::is_integral_v<Value_type>,
bool> =
true>
64 constexpr static const size_t components = 2;
67 constexpr static const size_t byte_size = components *
sizeof(
value_type);
87 constexpr
value_type operator[](
size_t i) const noexcept {
101 explicit operator pointer() noexcept {
return &x; }
115 return x == rhs.x && y == rhs.y;
123 { x=vx; y=vy;
return *
this; }
127 { x=xy[0]; y=xy[1];
return *
this; }
131 { x+=dx; y+=dy;
return *
this; }
135 { x*=sx; y*=sy;
return *
this; }
139 { x*=s; y*=s;
return *
this; }
176 rotate(sin, cos, ctr);
181 const value_type tmp = jau::round_to_int<float_type>( x0 * cos - y0 * sin ) + ctr.
x;
182 y = jau::round_to_int<float_type>( x0 * sin + y0 * cos ) + ctr.
y;
204 return jau::round_to_int<float_type>( std::sqrt(
static_cast<float_type> ( length_sq() )) );
215 x = jau::round_to_int<float_type>( x * invSqr );
216 y = jau::round_to_int<float_type>( x * invSqr );
223 return x == o.
x && y == o.
y;
228 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
240 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
246 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
252 std::enable_if_t<std::numeric_limits<T>::is_integer,
bool> =
true>
258 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>
266 return out << v.toString();
270 static_assert(
alignof(int) ==
alignof(
Vec2i));
271 static_assert(
sizeof(int)*2 ==
sizeof(
Vec2i));
std::string to_string(const alphabet &v) noexcept
std::enable_if< std::is_floating_point_v< T >, bool >::type 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 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 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
constexpr const jau::fraction_i64 zero(0l, 1lu)
zero is 0/1
constexpr const jau::fraction_i64 one(1l, 1lu)
one is 10^0 or 1/1
2D vector using two integer components.
constexpr Vector2I & operator-=(const Vector2I &rhs) noexcept
this = this - rhs, returns this.
constexpr Vector2I(const Vector2I &o) noexcept=default
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
jau::float_bytes< sizeof(value_type)>::type float_type
bool intersects(const Vector2I &o)
std::string toString() const noexcept
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.
const value_type & const_reference
constexpr Vector2I & normalize() noexcept
Normalize this vector in place, returns *this.
constexpr Vector2I & operator/=(const value_type s) noexcept
Divide this vector with given scale factor.
constexpr reference operator[](size_t i) noexcept
Returns writeable reference to component.
const value_type * const_iterator