17 #ifndef ASTRA_VECTOR2F_HPP
18 #define ASTRA_VECTOR2F_HPP
21 #include "capi/astra_ctypes.h"
44 ::astra_vector2f_t::x = rhs.x;
45 ::astra_vector2f_t::y = rhs.y;
56 inline operator ::astra_vector2f_t*() {
return this; }
57 inline operator const ::astra_vector2f_t*()
const {
return this; }
60 float length_squared()
const;
66 inline bool is_zero()
const;
78 Vector2f& operator*=(
const float& rhs);
79 Vector2f& operator/=(
const float& rhs);
84 double length = std::sqrt(v.x*v.x + v.y*v.y);
93 static_cast<float>(v.x / length),
94 static_cast<float>(v.y / length));
98 inline float Vector2f::length()
const
100 return std::sqrt(x * x + y * y);
103 inline float Vector2f::length_squared()
const
105 return x * x + y * y;
108 inline float Vector2f::dot(
const Vector2f& v)
const
110 return x * v.x + y * v.y;
113 inline Vector2f& Vector2f::operator+=(
const Vector2f& rhs)
115 this->x = this->x + rhs.x;
116 this->y = this->y + rhs.y;
120 inline Vector2f& Vector2f::operator-=(
const Vector2f& rhs)
122 this->x = this->x - rhs.x;
123 this->y = this->y - rhs.y;
127 inline Vector2f& Vector2f::operator*=(
const float& rhs)
129 this->x = this->x * rhs;
130 this->y = this->y * rhs;
134 inline Vector2f& Vector2f::operator/=(
const float& rhs)
136 this->x = this->x / rhs;
137 this->y = this->y / rhs;
141 inline Vector2f Vector2f::operator-()
143 return Vector2f(-this->x, -this->y);
146 inline bool operator==(
const Vector2f& lhs,
const Vector2f& rhs)
148 return lhs.x == rhs.x && lhs.y == rhs.y;
151 inline bool operator!=(
const Vector2f& lhs,
const Vector2f& rhs)
153 return !(lhs == rhs);
156 inline Vector2f operator+(
const Vector2f& lhs,
const Vector2f& rhs)
158 return Vector2f(lhs.x + rhs.x, lhs.y + rhs.y);
161 inline Vector2f operator-(
const Vector2f& lhs,
const Vector2f& rhs)
163 return Vector2f(lhs.x - rhs.x, lhs.y - rhs.y);
166 inline Vector2f operator*(
const Vector2f& lhs,
const float& rhs)
168 return Vector2f(lhs.x * rhs, lhs.y * rhs);
171 inline Vector2f operator*(
const float& lhs,
const Vector2f& rhs)
176 inline Vector2f operator/(
const Vector2f& lhs,
const float& rhs)
178 return Vector2f(lhs.x / rhs, lhs.y / rhs);
181 inline Vector2f Vector2f::zero()
187 inline bool Vector2f::is_zero()
const
189 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: Vector2f.hpp:30
Definition: astra_ctypes.h:27