5#ifndef JPP_POINT_3D_HPP_INCLUDED
6#define JPP_POINT_3D_HPP_INCLUDED
8#include <jimcpp/core/engine/irrMath.hpp>
36 vector3d<T> operator+(
const vector3d<T>& other)
const {
return vector3d<T>(
X + other.X,
Y + other.Y,
Z + other.Z); }
37 vector3d<T>& operator+=(
const vector3d<T>& other) {
X+=other.X;
Y+=other.Y;
Z+=other.Z;
return *
this; }
38 vector3d<T> operator+(
const T val)
const {
return vector3d<T>(
X + val,
Y + val,
Z + val); }
39 vector3d<T>& operator+=(
const T val) {
X+=val;
Y+=val;
Z+=val;
return *
this; }
41 vector3d<T> operator-(
const vector3d<T>& other)
const {
return vector3d<T>(
X - other.X,
Y - other.Y,
Z - other.Z); }
42 vector3d<T>& operator-=(
const vector3d<T>& other) {
X-=other.X;
Y-=other.Y;
Z-=other.Z;
return *
this; }
43 vector3d<T> operator-(
const T val)
const {
return vector3d<T>(
X - val,
Y - val,
Z - val); }
44 vector3d<T>& operator-=(
const T val) {
X-=val;
Y-=val;
Z-=val;
return *
this; }
46 vector3d<T> operator*(
const vector3d<T>& other)
const {
return vector3d<T>(
X * other.X,
Y * other.Y,
Z * other.Z); }
47 vector3d<T>& operator*=(
const vector3d<T>& other) {
X*=other.X;
Y*=other.Y;
Z*=other.Z;
return *
this; }
48 vector3d<T> operator*(
const T v)
const {
return vector3d<T>(
X * v,
Y * v,
Z * v); }
49 vector3d<T>& operator*=(
const T v) {
X*=v;
Y*=v;
Z*=v;
return *
this; }
51 vector3d<T> operator/(
const vector3d<T>& other)
const {
return vector3d<T>(
X / other.X,
Y / other.Y,
Z / other.Z); }
52 vector3d<T>& operator/=(
const vector3d<T>& other) {
X/=other.X;
Y/=other.Y;
Z/=other.Z;
return *
this; }
53 vector3d<T> operator/(
const T v)
const {
return vector3d<T>(
X/v,
Y/v,
Z/v); }
54 vector3d<T>& operator/=(
const T v) {
X/=v;
Y/=v;
Z/=v;
return *
this; }
56 T& operator [](
u32 index)
58 JPP_DEBUG_BREAK_IF(index>2)
63 const T& operator [](
u32 index)
const
65 JPP_DEBUG_BREAK_IF(index>2)
105 return this->
equals(other);
110 return !this->
equals(other);
124 vector3d<T>& set(
const vector3d<T>& p) {
X=p.X;
Y=p.Y;
Z=p.Z;
return *
this;}
198#if defined(_JPP_COMPILE_WITH_90_DEGREE_CAMERA)
202 if (::fabs(
l) < 0.000000001)
212 v =
X * l;
X = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
213 v =
Y * l;
Y = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
214 v =
Z * l;
Z = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
218#define normalize_x() normalize_camera_direction(core::vector3df(1.f, 0.f, 0.f))
219#define normalize_z() normalize_camera_direction(core::vector3df(0.f, 0.f, 1.f))
220#define normalize_y(v) core::vector3df(v).normalize_camera_direction(core::vector3df(0.f, 1.f, 0.f))
222#define normalize_x() normalize()
223#define normalize_z() normalize()
224#define normalize_y(v) v
320 X = (
T)((
f64)b.X + ( ( a.X - b.X ) *
d ));
321 Y = (
T)((
f64)b.Y + ( ( a.Y - b.Y ) *
d ));
322 Z = (
T)((
f64)b.Z + ( ( a.Z - b.Z ) *
d ));
354 const f64 z1 = core::squareroot(
X*
X +
Z*
Z);
481 angle.X = round32((
f32)(acos(
Y * core::reciprocal_squareroot(length)) *
RADTODEG64));
493 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:23
void rotateYZBy(f64 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:270
vector3d(T n)
Constructor with the same value for all elements.
Definition vector3d.hpp:30
T X
X coordinate of the vector.
Definition vector3d.hpp:450
vector3d(T nx, T ny, T nz)
Constructor with three different values.
Definition vector3d.hpp:28
void getAs4Values(T *array) const
Fills an array of 4 values with the vector data (usually floats).
Definition vector3d.hpp:431
vector3d< T > getInterpolated_quadratic(const vector3d< T > &v2, const vector3d< T > &v3, f64 d) const
Creates a quadratically interpolated vector between this and two other vectors.
Definition vector3d.hpp:299
vector3d< T > & interpolate(const vector3d< T > &a, const vector3d< T > &b, f64 d)
Sets this vector to the linearly interpolated vector between a and b.
Definition vector3d.hpp:318
void rotateXYBy(f64 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:255
vector3d< T > rotationToDirection(const vector3d< T > &forwards=vector3d< T >(0, 0, 1)) const
Builds a direction vector from (this) rotation vector.
Definition vector3d.hpp:399
bool operator==(const vector3d< T > &other) const
use weak float compare
Definition vector3d.hpp:103
vector3d< T > & invert()
Inverts the vector.
Definition vector3d.hpp:229
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:167
T getDistanceFromSQ(const vector3d< T > &other) const
Returns squared distance from another point.
Definition vector3d.hpp:149
vector3d< T > & setLength(T newlength)
Sets the length of the vector to a new value.
Definition vector3d.hpp:192
T Z
Z coordinate of the vector.
Definition vector3d.hpp:456
void rotateXZBy(f64 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:240
bool equals(const vector3d< T > &other, const T tolerance=(T) ROUNDING_ERROR_f32) const
returns if this vector equals the other one, taking floating point rounding errors into account
Definition vector3d.hpp:116
vector3d< T > getInterpolated(const vector3d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
Definition vector3d.hpp:287
T getDistanceFrom(const vector3d< T > &other) const
Get distance from another point.
Definition vector3d.hpp:142
T getLength() const
Get length of the vector.
Definition vector3d.hpp:127
T getLengthSQ() const
Get squared length of the vector.
Definition vector3d.hpp:132
vector3d< T > crossProduct(const vector3d< T > &p) const
Calculates the cross product with another vector.
Definition vector3d.hpp:157
vector3d< T > & normalize()
Normalizes the vector.
Definition vector3d.hpp:178
bool operator>=(const vector3d< T > &other) const
sort in order X, Y, Z. Equality with rounding tolerance.
Definition vector3d.hpp:79
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
Definition vector3d.hpp:135
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:341
bool operator<(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition vector3d.hpp:87
T Y
Y coordinate of the vector.
Definition vector3d.hpp:453
vector3d< T > getSphericalCoordinateAngles() const
Get the spherical coordinate angles.
Definition vector3d.hpp:372
void getAs3Values(T *array) const
Fills an array of 3 values with the vector data (usually floats).
Definition vector3d.hpp:441
bool operator>(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition vector3d.hpp:95
vector3d()
Default constructor (null vector).
Definition vector3d.hpp:26
const f64 RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.hpp:81
const f64 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
As of Jimcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
double f64
64 bit floating point variable.
Definition irrTypes.hpp:114
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110