MercuryDPM  Beta
Vector.cc File Reference
#include "Vector.h"
#include <Logger.h>

Go to the source code of this file.

## Functions

std::ostream & operator<< (std::ostream &os, const Vec3D &a)

std::istream & operator>> (std::istream &is, Vec3D &a)

Vec3D operator+ (const Mdouble a, const Vec3D &b)

Vec3D operator- (const Mdouble a, const Vec3D &b)

Vec3D operator- (const Vec3D &a)

Vec3D operator* (const Mdouble a, const Vec3D &b)

## Function Documentation

 Vec3D operator* ( const Mdouble a, const Vec3D & b )

Multiplies each element of a given vector (b) by a given scalar (a). NB: this is a global function and a friend of the Vec3D class. Gets called when a scalar multiplication of the form (Mdouble) * (Vec3D) is performed.

Parameters
 [in] a the scalar [in] b the vector
Returns
the resulting vector

Definition at line 522 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

523 {
524  return Vec3D(b.X * a, b.Y * a, b.Z * a);
525 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
 Vec3D operator+ ( const Mdouble a, const Vec3D & b )

Adds a scalar to the elements of given vector NB this is a global function and a friend of the Vec3D class. Gets called when addition operation of the form (Mdouble) + (Vec3D) is performed.

Parameters
 [in] a the scalar to be added [in] b the vector the scalar gets added to.
Returns
the resulting vector.

Definition at line 484 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

485 {
486  return Vec3D(b.X + a, b.Y + a, b.Z + a);
487 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
 Vec3D operator- ( const Mdouble a, const Vec3D & b )

Subtracts each element of a given vector from a scalar NB this is a global function and a friend of the Vec3D class. Gets called when subtraction operation of the form (Mdouble) - (Vec3D) is performed.

Parameters
 [in] a the scalar [in] b the vector to be subtracted the scalar gets subtracted from.
Returns
the resulting vector.

Definition at line 497 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

498 {
499  return Vec3D(a - b.X, a - b.Y, a - b.Z);
500 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
 Vec3D operator- ( const Vec3D & a )

Returns the negative of a given vector. NB: this is a global function and a friend of the Vec3D class. Gets called when a negation operation of the form - (Vec3D) is performed.

Parameters
 [in] a the vector to be negated
Returns
the negated vector

Definition at line 509 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

510 {
511  return Vec3D(-a.X, -a.Y, -a.Z);
512 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52
 std::ostream& operator<< ( std::ostream & os, const Vec3D & a )

Adds all elements of the vector to an output stream. NB: this is a global function and a friend of the Vec3D class!

Parameters
 [in] os the output stream, [in] a The vector of interest
Returns
the output stream with vector elements added

Definition at line 457 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

458 {
459  os << a.X << ' ' << a.Y << ' ' << a.Z;
460  return os;
461 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Mdouble Z
Definition: Vector.h:52
 std::istream& operator>> ( std::istream & is, Vec3D & a )

Reads all elements of a given vector from an input stream. NB: this is a global function and a friend of the Vec3D class!

Parameters
 [in,out] is the input stream [in,out] a the vector to be read in
Returns
the input stream from which the vector elements were read

Definition at line 470 of file Vector.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

471 {
472  is >> a.X >> a.Y >> a.Z;
473  return is;
474 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Mdouble Z
Definition: Vector.h:52