121 Vector3() : x(0.0f), y(0.0f), z(0.0f) {}
123 Vector3(T x, T y, T z) : x(x), y(y), z(z) {}
127 void Set(T x, T y, T z) {
134 float s = 1.0f / std::sqrt(x * x + y * y + z * z);
147 return Vector3(y * v.z - z * v.y,
152 T Dot(
const Vector3& v)
const {
153 return x * v.x + y * v.y + z * v.z;
157 return Vector3(x + v.x, y + v.y, z + v.z);
160 void operator+=(
const Vector3& v) {
166 void operator-=(
const Vector3& v) {
172 void operator/=(T s) {
179 return Vector3(x - v.x, y - v.y, z - v.z);
187 return Vector3(x * s, y * s, z * s);
191 return Vector3(x / s, y / s, z / s);
194 bool operator==(
const Vector3& v)
const {
195 return x == v.x && y == v.y && z == v.z;
199 return Vector3(x * (1 - t) + v.x * t,
200 y * (1 - t) + v.y * t,
201 z * (1 - t) + v.z * t);
205 return Vector3(a.x * (1 - t) + b.x * t,
206 a.y * (1 - t) + b.y * t,
207 a.z * (1 - t) + b.z * t);
211 return sqrtf(powf(a.x - b.x, 2) + powf(a.y - b.y, 2) + powf(a.z - b.z, 2));
214 const T* Pointer()
const {
218 template <
typename P>
236 Vector4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
242 void Set(T x, T y, T z, T w) {
250 T Dot(
const Vector4& v)
const {
251 return x * v.x + y * v.y + z * v.z + w * v.w;
255 return Vector4(-x, -y, -z, -w);
259 return Vector4(x * (1 - t) + v.x * t,
260 y * (1 - t) + v.y * t,
261 z * (1 - t) + v.z * t,
262 w * (1 - t) + v.w * t);
266 return Vector4(a.x * (1 - t) + b.x * t,
267 a.y * (1 - t) + b.y * t,
268 a.z * (1 - t) + b.z * t,
269 a.w * (1 - t) + b.w * t);
273 return sqrtf(powf(a.x - b.x, 2) + powf(a.y - b.y, 2) + powf(a.z - b.z, 2) + powf(a.w - b.w, 2));
277 return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
281 return Vector4(x * s, y * s, z * s, w * s);
284 const T* Pointer()
const {