MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 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]athe scalar
[in]bthe vector
Returns
the resulting vector

Definition at line 483 of file Vector.cc.

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

484 {
485  return Vec3D(b.X * a, b.Y * a, b.Z * a);
486 }
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]athe vector to be negated
Returns
the negated vector

Definition at line 470 of file Vector.cc.

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

471 {
472  return Vec3D(-a.X, -a.Y, -a.Z);
473 }
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]osthe output stream,
[in]aThe vector of interest
Returns
the output stream with vector elements added

Definition at line 444 of file Vector.cc.

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

445 {
446  os << a.X << ' ' << a.Y << ' ' << a.Z;
447  return os;
448 }
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]isthe input stream
[in,out]athe vector to be read in
Returns
the input stream from which the vector elements were read

Definition at line 457 of file Vector.cc.

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

458 {
459  is >> a.X >> a.Y >> a.Z;
460  return is;
461 }
Mdouble X
the vector components
Definition: Vector.h:52
Mdouble Y
Definition: Vector.h:52
Mdouble Z
Definition: Vector.h:52