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 7406859 : EFAPoint::EFAPoint(const double x, const double y, const double z) : _x(x), _y(y), _z(z) {} 15 : 16 : double 17 17548 : EFAPoint::operator()(const unsigned int i) const 18 : { 19 17548 : switch (i) 20 : { 21 8774 : case 0: 22 8774 : return _x; 23 8774 : case 1: 24 8774 : 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 2584 : EFAPoint::operator/=(const double a) 34 : { 35 2584 : _x /= a; 36 2584 : _y /= a; 37 2584 : _z /= a; 38 2584 : return *this; 39 : } 40 : 41 : EFAPoint & 42 18166 : EFAPoint::operator*=(const double a) 43 : { 44 18166 : _x *= a; 45 18166 : _y *= a; 46 18166 : _z *= a; 47 18166 : return *this; 48 : } 49 : 50 : EFAPoint & 51 63372 : EFAPoint::operator+=(const EFAPoint & point) 52 : { 53 63372 : _x += point._x; 54 63372 : _y += point._y; 55 63372 : _z += point._z; 56 63372 : return *this; 57 : } 58 : 59 : EFAPoint 60 62754 : EFAPoint::operator*(const double a) 61 : { 62 62754 : return EFAPoint(this->_x * a, this->_y * a, this->_z * a); 63 : } 64 : 65 : double 66 164293 : EFAPoint::operator*(const EFAPoint & point) 67 : { 68 164293 : return this->_x * point._x + this->_y * point._y + this->_z * point._z; 69 : } 70 : 71 : EFAPoint 72 8774 : EFAPoint::operator+(const EFAPoint & point) 73 : { 74 8774 : return EFAPoint(this->_x + point._x, this->_y + point._y, this->_z + point._z); 75 : } 76 : 77 : EFAPoint 78 139414 : EFAPoint::operator-(const EFAPoint & point) 79 : { 80 139414 : return EFAPoint(this->_x - point._x, this->_y - point._y, this->_z - point._z); 81 : } 82 : 83 : double 84 37497 : EFAPoint::norm() 85 : { 86 37497 : 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 9392 : EFAPoint::cross(const EFAPoint & point) 99 : { 100 9392 : double x = this->_y * point._z - this->_z * point._y; 101 9392 : double y = this->_z * point._x - this->_x * point._z; 102 9392 : double z = this->_x * point._y - this->_y * point._x; 103 9392 : return EFAPoint(x, y, z); 104 : }