EFAPoint.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7
8 #include "EFAPoint.h"
9 #include <cmath>
10 #include "EFAError.h"
11
12 EFAPoint::EFAPoint(const double x, const double y, const double z) : _x(x), _y(y), _z(z) {}
13
14 double
15 EFAPoint::operator()(const unsigned int i) const
16 {
17  switch (i)
18  {
19  case 0:
20  return _x;
21  case 1:
22  return _y;
23  case 2:
24  return _z;
25  default:
26  EFAError("EFAPoint: Out of index range.");
27  }
28 }
29
30 EFAPoint &
31 EFAPoint::operator/=(const double a)
32 {
33  _x /= a;
34  _y /= a;
35  _z /= a;
36  return *this;
37 }
38
39 EFAPoint &
40 EFAPoint::operator*=(const double a)
41 {
42  _x *= a;
43  _y *= a;
44  _z *= a;
45  return *this;
46 }
47
48 EFAPoint &
50 {
51  _x += point._x;
52  _y += point._y;
53  _z += point._z;
54  return *this;
55 }
56
58 {
59  return EFAPoint(this->_x * a, this->_y * a, this->_z * a);
60 }
61
62 double EFAPoint::operator*(const EFAPoint & point)
63 {
64  return this->_x * point._x + this->_y * point._y + this->_z * point._z;
65 }
66
69 {
70  return EFAPoint(this->_x + point._x, this->_y + point._y, this->_z + point._z);
71 }
72
75 {
76  return EFAPoint(this->_x - point._x, this->_y - point._y, this->_z - point._z);
77 }
78
79 double
81 {
82  return std::sqrt(_x * _x + _y * _y + _z * _z);
83 }
84
85 void
87 {
88  _x = 0.0;
89  _y = 0.0;
90  _z = 0.0;
91 }
92
94 EFAPoint::cross(const EFAPoint & point)
95 {
96  double x = this->_y * point._z - this->_z * point._y;
97  double y = this->_z * point._x - this->_x * point._z;
98  double z = this->_x * point._y - this->_y * point._x;
99  return EFAPoint(x, y, z);
100 }
EFAPoint & operator+=(const EFAPoint &point)
Definition: EFAPoint.C:49
EFAPoint operator-(const EFAPoint &point)
Definition: EFAPoint.C:74
EFAPoint cross(const EFAPoint &point)
Definition: EFAPoint.C:94
void zero()
Definition: EFAPoint.C:86
EFAPoint & operator*=(const double a)
Definition: EFAPoint.C:40
EFAPoint operator+(const EFAPoint &point)
Definition: EFAPoint.C:68
double _y
Definition: EFAPoint.h:18
double _z
Definition: EFAPoint.h:19
double norm()
Definition: EFAPoint.C:80
EFAPoint operator*(const double a)
Definition: EFAPoint.C:57
EFAPoint(const double x=0., const double y=0., const double z=0.)
Definition: EFAPoint.C:12
double _x
Definition: EFAPoint.h:17
double operator()(const unsigned int i) const
Definition: EFAPoint.C:15
EFAPoint & operator/=(const double a)
Definition: EFAPoint.C:31