5#ifndef DCPP_POINT_3D_HPP_INCLUDED
6#define DCPP_POINT_3D_HPP_INCLUDED
8#include <duckcpp/core/engine/irrMath.hpp>
45 vector3d<T> operator+(
const vector3d<T>& other)
const {
return vector3d<T>(
X + other.X,
Y + other.Y,
Z + other.Z); }
46 vector3d<T>& operator+=(
const vector3d<T>& other) {
X+=other.X;
Y+=other.Y;
Z+=other.Z;
return *
this; }
47 vector3d<T> operator+(
const T val)
const {
return vector3d<T>(
X + val,
Y + val,
Z + val); }
48 vector3d<T>& operator+=(
const T val) {
X+=val;
Y+=val;
Z+=val;
return *
this; }
50 vector3d<T> operator-(
const vector3d<T>& other)
const {
return vector3d<T>(
X - other.X,
Y - other.Y,
Z - other.Z); }
51 vector3d<T>& operator-=(
const vector3d<T>& other) {
X-=other.X;
Y-=other.Y;
Z-=other.Z;
return *
this; }
52 vector3d<T> operator-(
const T val)
const {
return vector3d<T>(
X - val,
Y - val,
Z - val); }
53 vector3d<T>& operator-=(
const T val) {
X-=val;
Y-=val;
Z-=val;
return *
this; }
55 vector3d<T> operator*(
const vector3d<T>& other)
const {
return vector3d<T>(
X * other.X,
Y * other.Y,
Z * other.Z); }
56 vector3d<T>& operator*=(
const vector3d<T>& other) {
X*=other.X;
Y*=other.Y;
Z*=other.Z;
return *
this; }
57 vector3d<T> operator*(
const T v)
const {
return vector3d<T>(
X * v,
Y * v,
Z * v); }
58 vector3d<T>& operator*=(
const T v) {
X*=v;
Y*=v;
Z*=v;
return *
this; }
60 vector3d<T> operator/(
const vector3d<T>& other)
const {
return vector3d<T>(
X / other.X,
Y / other.Y,
Z / other.Z); }
61 vector3d<T>& operator/=(
const vector3d<T>& other) {
X/=other.X;
Y/=other.Y;
Z/=other.Z;
return *
this; }
62 vector3d<T> operator/(
const T v)
const {
return vector3d<T>(
X/v,
Y/v,
Z/v); }
63 vector3d<T>& operator/=(
const T v) {
X/=v;
Y/=v;
Z/=v;
return *
this; }
67 DCPP_DEBUG_BREAK_IF(index>2)
74 DCPP_DEBUG_BREAK_IF(index>2)
114 return this->
equals(other);
119 return !this->
equals(other);
133 vector3d<T>& set(
const vector3d<T>& p) {
X=p.X;
Y=p.Y;
Z=p.Z;
return *
this;}
207#if defined(_DCPP_COMPILE_WITH_90_DEGREE_CAMERA)
211 if (::fabs(
l) < 0.000000001)
221 v =
X * l;
X = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
222 v =
Y * l;
Y = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
223 v =
Z * l;
Z = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
227#define normalize_x() normalize_camera_direction(dcpp::nub::vector3df(1.f, 0.f, 0.f))
228#define normalize_z() normalize_camera_direction(dcpp::nub::vector3df(0.f, 0.f, 1.f))
229#define normalize_y(v) dcpp::nub::vector3df(v).normalize_camera_direction(dcpp::nub::vector3df(0.f, 1.f, 0.f))
231#define normalize_x() normalize()
232#define normalize_z() normalize()
233#define normalize_y(v) v
496 template<
class S,
class T>
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.hpp:23
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
void rotateYZBy(dcpp::float64_kt degrees, const vector3d< T > ¢er=vector3d< T >())
Rotates the vector by a specified number of degrees around the X axis and the specified center.
Definition vector3d.hpp:279
void rotateXZBy(dcpp::float64_kt degrees, const vector3d< T > ¢er=vector3d< T >())
Rotates the vector by a specified number of degrees around the Y axis and the specified center.
Definition vector3d.hpp:249
T X
X coordinate of the vector.
Definition vector3d.hpp:459
T getLengthSQ() const
Get squared length of the vector.
Definition vector3d.hpp:141
void rotateXYBy(dcpp::float64_kt degrees, const vector3d< T > ¢er=vector3d< T >())
Rotates the vector by a specified number of degrees around the Z axis and the specified center.
Definition vector3d.hpp:264
void getAs3Values(T *array) const
Fills an array of 3 values with the vector data (usually floats).
Definition vector3d.hpp:450
T getDistanceFromSQ(const vector3d< T > &other) const
Returns squared distance from another point.
Definition vector3d.hpp:158
bool operator>(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition vector3d.hpp:104
vector3d< T > getSphericalCoordinateAngles() const
Get the spherical coordinate angles.
Definition vector3d.hpp:381
vector3d< T > & setLength(T newlength)
Sets the length of the vector to a new value.
Definition vector3d.hpp:201
vector3d< T > & invert()
Inverts the vector.
Definition vector3d.hpp:238
T getLength() const
Get length of the vector.
Definition vector3d.hpp:136
vector3d< T > getInterpolated_quadratic(const vector3d< T > &v2, const vector3d< T > &v3, dcpp::float64_kt d) const
Creates a quadratically interpolated vector between this and two other vectors.
Definition vector3d.hpp:308
vector3d< T > rotationToDirection(const vector3d< T > &forwards=vector3d< T >(0, 0, 1)) const
Builds a direction vector from (this) rotation vector.
Definition vector3d.hpp:408
bool operator<(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition vector3d.hpp:96
vector3d(T n)
Constructor with the same value for all elements.
Definition vector3d.hpp:39
T Y
Y coordinate of the vector.
Definition vector3d.hpp:462
bool operator>=(const vector3d< T > &other) const
sort in order X, Y, Z. Equality with rounding tolerance.
Definition vector3d.hpp:88
vector3d< T > & interpolate(const vector3d< T > &a, const vector3d< T > &b, dcpp::float64_kt d)
Sets this vector to the linearly interpolated vector between a and b.
Definition vector3d.hpp:327
T Z
Z coordinate of the vector.
Definition vector3d.hpp:465
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
Definition vector3d.hpp:144
vector3d< T > & normalize()
Normalizes the vector.
Definition vector3d.hpp:187
bool equals(const vector3d< T > &other, const T tolerance=(T) ROUNDING_ERROR_Float32) const
returns if this vector equals the other one, taking floating point rounding errors into account
Definition vector3d.hpp:125
vector3d< T > crossProduct(const vector3d< T > &p) const
Calculates the cross product with another vector.
Definition vector3d.hpp:166
T getDistanceFrom(const vector3d< T > &other) const
Get distance from another point.
Definition vector3d.hpp:151
bool operator==(const vector3d< T > &other) const
use weak float compare
Definition vector3d.hpp:112
vector3d()
Default constructor (null vector).
Definition vector3d.hpp:35
vector3d< T > getInterpolated(const vector3d< T > &other, dcpp::float64_kt d) const
Creates an interpolated vector between this vector and another vector.
Definition vector3d.hpp:296
bool isBetweenPoints(const vector3d< T > &begin, const vector3d< T > &end) const
Returns if this vector interpreted as a point is on a line between two other points.
Definition vector3d.hpp:176
void getAs4Values(T *array) const
Fills an array of 4 values with the vector data (usually floats).
Definition vector3d.hpp:440
vector3d(T nx, T ny, T nz)
Constructor with three different values.
Definition vector3d.hpp:37
vector3d< T > getHorizontalAngle() const
Get the rotations that would make a (0,0,1) direction vector point in the same direction as this dire...
Definition vector3d.hpp:350
vector3d< dcpp::int32_kt > vector3di
using type alias for an integer 3d vector.
Definition vector3d.hpp:22
const dcpp::float64_kt DEGTORAD64
64bit constant for converting from degrees to radians (formally known as GRAD_PI2)
Definition irrMath.hpp:78
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition irrMath.hpp:243
const dcpp::float64_kt RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.hpp:81
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
double float64_kt
64 bit floating point variable.
Definition irrTypes.hpp:112
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72