-
namespace Vectorium
-
class Vector3D
The Vector3D class.Public variable and methods that you can use are as follows:-
-
double i; double j; double k;
Public variables of the class that can be accessed and modified
i
is the x componentj
is the y componentk
is the z component -
Vector3D(double i, double j, double k)
Constructor for the class. Takes in the x, y and z components of the vector as arguments.
-
Vector3D()
Default constructor for the class. Initializes the vector to (0, 0, 0).
-
Vector3D(const Vector3D &other); Vector3D(Vector3D &&other);
Copy constructor for the class. Takes in a vector as argument and initializes the vector to the vector passed as argument.
-
Vector3D& operator=(const Vector3D &other); Vector3D &operator=(Vector3D &&other);
Copy assignment operator for the class. Takes in a vector as argument and assigns the vector to the vector passed as argument.
-
bool operator==(const Vector3D &other);
Returns true if the vector *this is equal to the vector
other
. -
bool operator!=(const Vector3D &other);
Returns true if the vector *this is not equal to the vector
other
. -
Vector3D operator+(Vector3D v)
Returns the sum of the vector *this and the vector
v
. -
Vector3D operator-(Vector3D v)
Returns the difference of the vector *this and the vector
v
. -
Vector3D operator*(double scalar)
Returns the product of the vector *this and the scalar
scalar
. -
Vector3D operator/(double scalar)
Returns the division of the vector *this and the scalar
scalar
. -
Vector3D& operator+=(const Vector3D &other); Vector3D& operator-=(const Vector3D &other); Vector3D& operator*=(double other); Vector3D& operator/=(double other);
They have the usual meaning
-
double dot(Vector3D v)
Returns the dot product of the vector *this and the vector
v
. -
Vector3D cross(Vector3D v)
Returns the cross product of the vector *this and the vector
v
. -
double dot(double v,double O)
Returns the dot product of the vector *this and the vector
v
where the angle between them isO
. -
double cross(double v,double O)
Returns the magnetude cross product of the vector *this and the vector
v
where the angle between them isO
. -
double mag()
Returns the magnitude of the vector *this.
-
double mag2()
Returns the square of the magnitude of the vector *this.
-
Vector3D unit()
Returns the unit vector of the vector *this.
-
double distance(Vector3D v)
Returns the distance between the vector *this and the vector
v
. -
double distance2(Vector3D v)
Returns the square of the distance between the vector *this and the vector
v
. -
double angle(Vector3D v)
Returns the angle between the vector *this and the vector
v
. -
double angle(Vector3D v,Vector3D o)
Returns the angle between the vector *this and the vector
v
when the centre is vectoro
-
Vector3D projection(Vector3D v)
Returns the projection of the vector *this on the vector
v
. -
Vector3D rejection(Vector3D v)
Returns the rejection of the vector *this on the vector
v
. -
Vector3D rotatexy(double o)
Returns the vector *this rotated by an angle
o
along xy plane in anti-clockwise direction -
Vector3D rotateyz(double o)
Returns the vector *this rotated by an angle
o
along yz plane in anti-clockwise direction -
Vector3D rotatexz(double o)
Returns the vector *this rotated by an angle
o
along xz plane in anti-clockwise direction
-
-
Vector3D operator*(double a,const Vector3D &b);
Returns the product of the scalar
a
and the vectorb
. -
double dot(double a,double b,double o);
Returns the dot product of the vector
a
and the vectorb
that make an angleo
with each other. -
double cross(double a,double b,double o);
Returns the magnitude of the cross product of the vector
a
and the vectorb
that make an angleo
with each other. -
std::ostream &operator<<(std::ostream &os, const Vector3D &v);
Prints the vector
v
to the output streamos
-
double PerlinNoise(Vector3D v);
Returns the Perlin noise value of the vector
v
. -
double PerlinNoise(Vector3D v,double s);
Returns the Perlin noise value of the vector
v
using the seeds
.
-