5 #ifndef __IRR_POINT_3D_H_INCLUDED__ 6 #define __IRR_POINT_3D_H_INCLUDED__ 109 return this->
equals(other);
114 return !this->
equals(other);
141 return X*other.
X +
Y*other.
Y +
Z*other.
Z;
199 return (*
this *= newlength);
217 f64 cs = cos(degrees);
218 f64 sn = sin(degrees);
221 set((T)(
X*cs -
Z*sn),
Y, (T)(
X*sn +
Z*cs));
232 f64 cs = cos(degrees);
233 f64 sn = sin(degrees);
236 set((T)(
X*cs -
Y*sn), (T)(
X*sn +
Y*cs),
Z);
247 f64 cs = cos(degrees);
248 f64 sn = sin(degrees);
251 set(
X, (T)(
Y*cs -
Z*sn), (T)(
Y*sn +
Z*cs));
263 const f64 inv = 1.0 - d;
264 return vector3d<T>((T)(other.
X*inv +
X*d), (T)(other.
Y*inv +
Y*d), (T)(other.
Z*inv +
Z*d));
276 const f64 inv = (T) 1.0 - d;
277 const f64 mul0 = inv * inv;
278 const f64 mul1 = (T) 2.0 * d * inv;
279 const f64 mul2 = d * d;
282 (T)(
Y * mul0 +
v2.Y * mul1 +
v3.Y * mul2),
283 (T)(
Z * mul0 +
v2.Z * mul1 +
v3.Z * mul2));
294 X = (T)((
f64)
b.X + ( (
a.X -
b.X ) * d ));
295 Y = (T)((
f64)
b.Y + ( (
a.Y -
b.Y ) * d ));
296 Z = (T)((
f64)
b.Z + ( (
a.Z -
b.Z ) * d ));
382 const f64 srsp = sr*sp;
383 const f64 crsp = cr*sp;
385 const f64 pseudoMatrix[] = {
386 ( cp*cy ), ( cp*sy ), ( -sp ),
387 ( srsp*cy-cr*sy ), ( srsp*sy+cr*cy ), ( sr*cp ),
388 ( crsp*cy+sr*sy ), ( crsp*sy-sr*cy ), ( cr*cp )};
391 (T)(forwards.X * pseudoMatrix[0] +
392 forwards.Y * pseudoMatrix[3] +
393 forwards.Z * pseudoMatrix[6]),
394 (T)(forwards.X * pseudoMatrix[1] +
395 forwards.Y * pseudoMatrix[4] +
396 forwards.Z * pseudoMatrix[7]),
397 (T)(forwards.X * pseudoMatrix[2] +
398 forwards.Y * pseudoMatrix[5] +
399 forwards.Z * pseudoMatrix[8]));
467 template<
class S,
class T>
vector3d< T > & invert()
Inverts the vector.
vector3d< T > & operator-=(const T val)
const f64 RADTODEG64
64bit constant for converting from radians to degrees
vector3d< T > crossProduct(const vector3d< T > &p) const
Calculates the cross product with another vector.
vector3d< T > & operator=(const vector3d< T > &other)
REALINLINE s32 round32(f32 x)
T Y
Y coordinate of the vector.
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
T getDistanceFromSQ(const vector3d< T > &other) const
Returns squared distance from another point.
vector3d< T > & operator-=(const vector3d< T > &other)
void getAs4Values(T *array) const
Fills an array of 4 values with the vector data (usually floats).
float f32
32 bit floating point variable.
vector3d< T > getInterpolated(const vector3d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
vector3d(T nx, T ny, T nz)
Constructor with three different values.
bool operator!=(const vector3d< T > &other) const
REALINLINE f32 squareroot(const f32 f)
bool operator<(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
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.
vector3d< T > operator-(const T val) const
T X
X coordinate of the vector.
vector3d< T > rotationToDirection(const vector3d< T > &forwards=vector3d< T >(0, 0, 1)) const
Builds a direction vector from (this) rotation vector.
vector3d< T > & set(const T nx, const T ny, const T nz)
Everything in the Irrlicht Engine can be found in this namespace.
3d vector template class with lots of operators and methods.
GLfloat GLfloat GLfloat v2
double f64
64 bit floating point variable.
bool operator==(const vector3d< T > &other) const
use weak float compare
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
vector3d(const vector3d< T > &other)
Copy constructor.
vector3d< T > & operator/=(const vector3d< T > &other)
const f64 DEGTORAD64
64bit constant for converting from degrees to radians (formally known as GRAD_PI2)
const f32 ROUNDING_ERROR_f32
CMatrix4< T > operator *(const T scalar, const CMatrix4< T > &mat)
vector3d< T > operator/(const vector3d< T > &other) const
GLfloat GLfloat GLfloat GLfloat v3
vector3d< T > & setLength(T newlength)
Sets the length of the vector to a new value.
const T & operator [](u32 index) const
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
bool operator>=(const vector3d< T > &other) const
sort in order X, Y, Z. Equality with rounding tolerance.
signed int s32
32 bit signed variable.
unsigned int u32
32 bit unsigned variable.
vector3d< T > & operator+=(const vector3d< T > &other)
vector3d< s32 > vector3di
Typedef for an integer 3d vector.
vector3d< T > & operator+=(const T val)
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
vector3d< T > & operator/=(const T v)
vector3d< T > & normalize()
Normalizes the vector.
vector3d< T > operator/(const T v) const
vector3d(T n)
Constructor with the same value for all elements.
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
T & operator [](u32 index)
bool operator>(const vector3d< T > &other) const
sort in order X, Y, Z. Difference must be above rounding tolerance.
vector3d< T > operator+(const T val) const
Self reallocating template array (like stl vector) with additional features.
GLboolean GLboolean GLboolean b
vector3d< T > operator-() const
vector3d< T > & operator *=(const vector3d< T > &other)
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.
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.
T Z
Z coordinate of the vector.
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.
void getAs3Values(T *array) const
Fills an array of 3 values with the vector data (usually floats).
T getDistanceFrom(const vector3d< T > &other) const
Get distance from another point.
GLboolean GLboolean GLboolean GLboolean a
T getLength() const
Get length of the vector.
vector3d< T > getSphericalCoordinateAngles() const
Get the spherical coordinate angles.
T getLengthSQ() const
Get squared length of the vector.
vector3d< T > operator+(const vector3d< T > &other) const
vector3d< T > getHorizontalAngle() const
Get the rotations that would make a (0,0,1) direction vector point in the same direction as this dire...
GLuint GLsizei GLsizei * length
bool operator<=(const vector3d< T > &other) const
sort in order X, Y, Z. Equality with rounding tolerance.
REALINLINE f64 reciprocal_squareroot(const f64 x)
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.
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.
vector3d< T > & set(const vector3d< T > &p)
vector3d< T > operator-(const vector3d< T > &other) const
vector3d()
Default constructor (null vector).
vector3d< T > operator *(const vector3d< T > &other) const