17 #ifndef ASTRA_VECTOR2I_HPP
18 #define ASTRA_VECTOR2I_HPP
22 #include "capi/astra_ctypes.h"
45 ::astra_vector2i_t::x = rhs.x;
46 ::astra_vector2i_t::y = rhs.y;
57 inline operator ::astra_vector2i_t*() {
return this; }
58 inline operator const ::astra_vector2i_t*()
const {
return this; }
61 std::int32_t length_squared()
const;
62 std::int32_t dot(
const Vector2i& v)
const;
66 static inline const Vector2i& zero();
68 inline bool is_zero()
const;
80 Vector2i& operator*=(
const std::int32_t rhs);
81 Vector2i& operator/=(
const std::int32_t rhs);
86 double length = std::sqrt(
87 static_cast<float>(v.x*v.x + v.y*v.y));
96 static_cast<std::int32_t
>(v.x / length),
97 static_cast<std::int32_t
>(v.y / length));
101 inline float Vector2i::length()
const
104 static_cast<float>(x * x + y * y));
107 inline std::int32_t Vector2i::length_squared()
const
109 return x * x + y * y;
113 inline std::int32_t Vector2i::dot(
const Vector2i& v)
const
115 return x * v.x + y * v.y;
118 inline Vector2i& Vector2i::operator+=(
const Vector2i& rhs)
120 this->x = this->x + rhs.x;
121 this->y = this->y + rhs.y;
125 inline Vector2i& Vector2i::operator-=(
const Vector2i& rhs)
127 this->x = this->x - rhs.x;
128 this->y = this->y - rhs.y;
132 inline Vector2i& Vector2i::operator*=(
const std::int32_t rhs)
134 this->x =
static_cast<std::int32_t
>(this->x * rhs);
135 this->y =
static_cast<std::int32_t
>(this->y * rhs);
139 inline Vector2i& Vector2i::operator/=(
const std::int32_t rhs)
141 this->x =
static_cast<std::int32_t
>(this->x / rhs);
142 this->y =
static_cast<std::int32_t
>(this->y / rhs);
147 inline Vector2i Vector2i::operator-()
149 return Vector2i(-this->x, -this->y);
152 inline bool operator==(
const Vector2i& lhs,
const Vector2i& rhs)
154 return lhs.x == rhs.x && lhs.y == rhs.y;
157 inline bool operator!=(
const Vector2i& lhs,
const Vector2i& rhs)
159 return !(lhs == rhs);
162 inline Vector2i operator+(
const Vector2i& lhs,
const Vector2i& rhs)
164 return Vector2i(lhs.x + rhs.x, lhs.y + rhs.y);
167 inline Vector2i operator-(
const Vector2i& lhs,
const Vector2i& rhs)
169 return Vector2i(lhs.x - rhs.x, lhs.y - rhs.y);
172 inline Vector2i operator*(
const Vector2i& lhs,
const std::int32_t rhs)
175 static_cast<std::int32_t
>(lhs.x * rhs),
176 static_cast<std::int32_t
>(lhs.y * rhs));
179 inline Vector2i operator*(
const std::int32_t lhs,
const Vector2i& rhs)
184 inline Vector2i operator/(
const Vector2i& lhs,
const std::int32_t rhs)
187 static_cast<std::int32_t
>(lhs.x / rhs),
188 static_cast<std::int32_t
>(lhs.y / rhs));
191 inline const Vector2i& Vector2i::zero()
193 static Vector2i zero;
197 inline bool Vector2i::is_zero()
const
199 return *
this == zero();
bool operator!=(const ImageStreamMode &lhs, const ImageStreamMode &rhs)
compare is ImageStreamMode not equal
Definition: Image.hpp:247
bool operator==(const ImageStreamMode &lhs, const ImageStreamMode &rhs)
compare is ImageStreamMode equal
Definition: Image.hpp:230
Represents a float 2d vector
Definition: Vector2i.hpp:31
Definition: astra_ctypes.h:22