AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Vec3D Class Reference

#include "vec3d.h"

Public Member Functions

 Vec3D (float x0=0.0f, float y0=0.0f, float z0=0.0f)
 
 Vec3D (const Vec3D &v)
 
Vec3Doperator= (const Vec3D &v)
 
Vec3D operator+ (const Vec3D &v) const
 
Vec3D operator- (const Vec3D &v) const
 
float operator* (const Vec3D &v) const
 
Vec3D operator* (float d) const
 
Vec3D operator% (const Vec3D &v) const
 
Vec3Doperator+= (const Vec3D &v)
 
Vec3Doperator-= (const Vec3D &v)
 
Vec3Doperator*= (float d)
 
float lengthSquared () const
 
float length () const
 
Vec3Dnormalize ()
 
Vec3D operator~ () const
 
 operator float * ()
 

Public Attributes

float x
 
float y
 
float z
 

Friends

Vec3D operator* (float d, const Vec3D &v)
 
std::istream & operator>> (std::istream &in, Vec3D &v)
 
std::ostream & operator<< (std::ostream &out, const Vec3D &v)
 

Detailed Description

Constructor & Destructor Documentation

◆ Vec3D() [1/2]

Vec3D::Vec3D ( float  x0 = 0.0f,
float  y0 = 0.0f,
float  z0 = 0.0f 
)
inline
29: x(x0), y(y0), z(z0) {}
float x
Definition: vec3d.h:27
float y
Definition: vec3d.h:27
float z
Definition: vec3d.h:27

◆ Vec3D() [2/2]

Vec3D::Vec3D ( const Vec3D v)
inline
31: x(v.x), y(v.y), z(v.z) {}

Member Function Documentation

◆ length()

float Vec3D::length ( ) const
inline
105 {
106 return std::sqrt(x * x + y * y + z * z);
107 }

References x, y, and z.

Referenced by normalize().

◆ lengthSquared()

float Vec3D::lengthSquared ( ) const
inline
100 {
101 return x * x + y * y + z * z;
102 }

References x, y, and z.

◆ normalize()

Vec3D & Vec3D::normalize ( )
inline
110 {
111 this->operator*= (1.0f / length());
112 return *this;
113 }
Vec3D & operator*=(float d)
Definition: vec3d.h:91
float length() const
Definition: vec3d.h:104

References length(), and operator*=().

Referenced by operator~().

◆ operator float *()

Vec3D::operator float * ( )
inline
135 {
136 return (float*)this;
137 }

◆ operator%()

Vec3D Vec3D::operator% ( const Vec3D v) const
inline
70 {
71 Vec3D r(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
72 return r;
73 }
Definition: vec3d.h:25

References x, y, and z.

◆ operator*() [1/2]

float Vec3D::operator* ( const Vec3D v) const
inline
54 {
55 return x * v.x + y * v.y + z * v.z;
56 }

References x, y, and z.

◆ operator*() [2/2]

Vec3D Vec3D::operator* ( float  d) const
inline
59 {
60 Vec3D r(x * d, y * d, z * d);
61 return r;
62 }

References x, y, and z.

◆ operator*=()

Vec3D & Vec3D::operator*= ( float  d)
inline
92 {
93 x *= d;
94 y *= d;
95 z *= d;
96 return *this;
97 }

References x, y, and z.

Referenced by normalize().

◆ operator+()

Vec3D Vec3D::operator+ ( const Vec3D v) const
inline
42 {
43 Vec3D r(x + v.x, y + v.y, z + v.z);
44 return r;
45 }

References x, y, and z.

◆ operator+=()

Vec3D & Vec3D::operator+= ( const Vec3D v)
inline
76 {
77 x += v.x;
78 y += v.y;
79 z += v.z;
80 return *this;
81 }

References x, y, and z.

◆ operator-()

Vec3D Vec3D::operator- ( const Vec3D v) const
inline
48 {
49 Vec3D r(x - v.x, y - v.y, z - v.z);
50 return r;
51 }

References x, y, and z.

◆ operator-=()

Vec3D & Vec3D::operator-= ( const Vec3D v)
inline
84 {
85 x -= v.x;
86 y -= v.y;
87 z -= v.z;
88 return *this;
89 }

References x, y, and z.

◆ operator=()

Vec3D & Vec3D::operator= ( const Vec3D v)
inline
34 {
35 x = v.x;
36 y = v.y;
37 z = v.z;
38 return *this;
39 }

References x, y, and z.

◆ operator~()

Vec3D Vec3D::operator~ ( ) const
inline
116 {
117 Vec3D r(*this);
118 r.normalize();
119 return r;
120 }

References normalize().

Friends And Related Function Documentation

◆ operator*

Vec3D operator* ( float  d,
const Vec3D v 
)
friend
65 {
66 return v * d;
67 }

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const Vec3D v 
)
friend
129 {
130 out << v.x << " " << v.y << " " << v.z;
131 return out;
132 }

◆ operator>>

std::istream & operator>> ( std::istream &  in,
Vec3D v 
)
friend
123 {
124 in >> v.x >> v.y >> v.z;
125 return in;
126 }

Member Data Documentation

◆ x

◆ y

◆ z