Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "EFAPoint.h" 11 : #include <cmath> 12 : #include "EFAError.h" 13 : 14 4559242 : EFAPoint::EFAPoint(const double x, const double y, const double z) : _x(x), _y(y), _z(z) {} 15 : 16 : double 17 17412 : EFAPoint::operator()(const unsigned int i) const 18 : { 19 17412 : switch (i) 20 : { 21 8706 : case 0: 22 8706 : return _x; 23 8706 : case 1: 24 8706 : return _y; 25 0 : case 2: 26 0 : return _z; 27 0 : default: 28 0 : EFAError("EFAPoint: Out of index range."); 29 : } 30 : } 31 : 32 : EFAPoint & 33 7464 : EFAPoint::operator/=(const double a) 34 : { 35 7464 : _x /= a; 36 7464 : _y /= a; 37 7464 : _z /= a; 38 7464 : return *this; 39 : } 40 : 41 : EFAPoint & 42 11194 : EFAPoint::operator*=(const double a) 43 : { 44 11194 : _x *= a; 45 11194 : _y *= a; 46 11194 : _z *= a; 47 11194 : return *this; 48 : } 49 : 50 : EFAPoint & 51 79964 : EFAPoint::operator+=(const EFAPoint & point) 52 : { 53 79964 : _x += point._x; 54 79964 : _y += point._y; 55 79964 : _z += point._z; 56 79964 : return *this; 57 : } 58 : 59 : EFAPoint 60 61646 : EFAPoint::operator*(const double a) 61 : { 62 61646 : return EFAPoint(this->_x * a, this->_y * a, this->_z * a); 63 : } 64 : 65 : double 66 130913 : EFAPoint::operator*(const EFAPoint & point) 67 : { 68 130913 : return this->_x * point._x + this->_y * point._y + this->_z * point._z; 69 : } 70 : 71 : EFAPoint 72 8706 : EFAPoint::operator+(const EFAPoint & point) 73 : { 74 8706 : return EFAPoint(this->_x + point._x, this->_y + point._y, this->_z + point._z); 75 : } 76 : 77 : EFAPoint 78 137042 : EFAPoint::operator-(const EFAPoint & point) 79 : { 80 137042 : return EFAPoint(this->_x - point._x, this->_y - point._y, this->_z - point._z); 81 : } 82 : 83 : double 84 30401 : EFAPoint::norm() 85 : { 86 30401 : return std::sqrt(_x * _x + _y * _y + _z * _z); 87 : } 88 : 89 : void 90 0 : EFAPoint::zero() 91 : { 92 0 : _x = 0.0; 93 0 : _y = 0.0; 94 0 : _z = 0.0; 95 0 : } 96 : 97 : EFAPoint 98 9008 : EFAPoint::cross(const EFAPoint & point) 99 : { 100 9008 : double x = this->_y * point._z - this->_z * point._y; 101 9008 : double y = this->_z * point._x - this->_x * point._z; 102 9008 : double z = this->_x * point._y - this->_y * point._x; 103 9008 : return EFAPoint(x, y, z); 104 : }