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 7400939 : EFAPoint::EFAPoint(const double x, const double y, const double z) : _x(x), _y(y), _z(z) {} 15 : 16 : double 17 17452 : EFAPoint::operator()(const unsigned int i) const 18 : { 19 17452 : switch (i) 20 : { 21 8726 : case 0: 22 8726 : return _x; 23 8726 : case 1: 24 8726 : 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 18118 : EFAPoint::operator*=(const double a) 43 : { 44 18118 : _x *= a; 45 18118 : _y *= a; 46 18118 : _z *= a; 47 18118 : return *this; 48 : } 49 : 50 : EFAPoint & 51 63180 : EFAPoint::operator+=(const EFAPoint & point) 52 : { 53 63180 : _x += point._x; 54 63180 : _y += point._y; 55 63180 : _z += point._z; 56 63180 : return *this; 57 : } 58 : 59 : EFAPoint 60 62514 : EFAPoint::operator*(const double a) 61 : { 62 62514 : return EFAPoint(this->_x * a, this->_y * a, this->_z * a); 63 : } 64 : 65 : double 66 163621 : EFAPoint::operator*(const EFAPoint & point) 67 : { 68 163621 : return this->_x * point._x + this->_y * point._y + this->_z * point._z; 69 : } 70 : 71 : EFAPoint 72 8726 : EFAPoint::operator+(const EFAPoint & point) 73 : { 74 8726 : return EFAPoint(this->_x + point._x, this->_y + point._y, this->_z + point._z); 75 : } 76 : 77 : EFAPoint 78 138854 : EFAPoint::operator-(const EFAPoint & point) 79 : { 80 138854 : return EFAPoint(this->_x - point._x, this->_y - point._y, this->_z - point._z); 81 : } 82 : 83 : double 84 37353 : EFAPoint::norm() 85 : { 86 37353 : 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 : }