17 #ifndef ASTRA_VECTOR3F_HPP
18 #define ASTRA_VECTOR3F_HPP
21 #include "capi/astra_ctypes.h"
45 ::astra_vector3f_t::x = rhs.x;
46 ::astra_vector3f_t::y = rhs.y;
47 ::astra_vector3f_t::z = rhs.z;
59 inline operator ::astra_vector3f_t*() {
return this; }
60 inline operator const ::astra_vector3f_t*()
const {
return this; }
63 float length_squared()
const;
78 Vector3f& operator*=(
const float& rhs);
79 Vector3f& operator/=(
const float& rhs);
90 inline float Vector3f::length()
const
92 return std::sqrt(x * x + y * y + z * z);
95 inline float Vector3f::length_squared()
const
97 return x * x + y * y + z * z;
100 inline float Vector3f::dot(
const Vector3f& v)
const
102 return x * v.x + y * v.y + z * v.z;
105 inline Vector3f Vector3f::cross(
const Vector3f& v)
const
107 return Vector3f(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
110 inline Vector3f Vector3f::normalize(Vector3f v)
112 double length = std::sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
115 return Vector3f(0.0f, 0.0f, 0.0f);
120 static_cast<float>(v.x / length),
121 static_cast<float>(v.y / length),
122 static_cast<float>(v.z / length));
126 inline Vector3f Vector3f::zero()
128 static Vector3f zero;
132 inline bool Vector3f::is_zero()
const
134 return *
this == zero();
137 inline Vector3f& Vector3f::operator+=(
const Vector3f& rhs)
139 this->x = this->x + rhs.x;
140 this->y = this->y + rhs.y;
141 this->z = this->z + rhs.z;
145 inline Vector3f& Vector3f::operator-=(
const Vector3f& rhs)
147 this->x = this->x - rhs.x;
148 this->y = this->y - rhs.y;
149 this->z = this->z - rhs.z;
153 inline Vector3f& Vector3f::operator*=(
const float& rhs)
155 this->x = this->x * rhs;
156 this->y = this->y * rhs;
157 this->z = this->z * rhs;
161 inline Vector3f& Vector3f::operator/=(
const float& rhs)
163 this->x = this->x / rhs;
164 this->y = this->y / rhs;
165 this->z = this->z / rhs;
169 inline Vector3f Vector3f::operator-()
171 return Vector3f(-this->x, -this->y, -this->z);
174 inline bool operator==(
const Vector3f& lhs,
const Vector3f& rhs)
176 return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z;
179 inline bool operator!=(
const Vector3f& lhs,
const Vector3f& rhs)
181 return !(lhs == rhs);
184 inline Vector3f operator+(
const Vector3f& lhs,
const Vector3f& rhs)
186 return Vector3f(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
189 inline Vector3f operator-(
const Vector3f& lhs,
const Vector3f& rhs)
191 return Vector3f(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
194 inline Vector3f operator*(
const Vector3f& lhs,
const float& rhs)
196 return Vector3f(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs);
199 inline Vector3f operator*(
const float& lhs,
const Vector3f& rhs)
204 inline Vector3f operator/(
const Vector3f& lhs,
const float& rhs)
206 return Vector3f(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs);
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 3d vector
Definition: Vector3f.hpp:30
Definition: astra_ctypes.h:32