28 #ifndef _math_scmat_vector3_h
29 #define _math_scmat_vector3_h
37 #include <util/misc/exenv.h>
38 #include <util/keyval/keyval.h>
53 _v[0] = p[0]; _v[1] = p[1]; _v[2] = p[2];
55 SCVector3(
double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
57 _v[0] = x; _v[1] = y; _v[2] = z;
60 _v[0] = p._v[0]; _v[1] = p._v[1]; _v[2] = p._v[2];
67 void operator = (
const double *x) {
77 void operator = (
double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
88 void operator *= (
double m) { _v[0] *= m; _v[1] *= m; _v[2] *= m; }
91 result._v[0] = _v[0] + v._v[0];
92 result._v[1] = _v[1] + v._v[1];
93 result._v[2] = _v[2] + v._v[2];
98 result._v[0] = _v[0] - v._v[0];
99 result._v[1] = _v[1] - v._v[1];
100 result._v[2] = _v[2] - v._v[2];
104 return _v[0]*v._v[0] + _v[1]*v._v[1] + _v[2]*v._v[2]; }
108 void spherical_coord(
double theta,
double phi,
110 void spherical_to_cartesian(
SCVector3&cart)
const;
111 double maxabs()
const;
115 double norm()
const {
return sqrt(this->dot(*
this)); }
116 double& elem(
int xyz) {
return _v[xyz]; }
117 const double& elem(
int xyz)
const {
return _v[xyz]; }
118 double& operator [] (
int i) {
return _v[i]; }
119 const double& operator [] (
int i)
const {
return _v[i]; }
120 double& operator () (
int i) {
return _v[i]; }
121 const double& operator () (
int i)
const {
return _v[i]; }
122 const double* data()
const {
return _v; }
123 double* data() {
return _v; }
124 double& x() {
return _v[0]; }
125 double& y() {
return _v[1]; }
126 double& z() {
return _v[2]; }
127 const double& x()
const {
return _v[0]; }
128 const double& y()
const {
return _v[1]; }
129 const double& z()
const {
return _v[2]; }
130 double& r() {
return _v[0]; }
131 double& theta() {
return _v[1]; }
132 double& phi() {
return _v[2]; }
133 const double& r()
const {
return _v[0]; }
134 const double& theta()
const {
return _v[1]; }
135 const double& phi()
const {
return _v[2]; }
139 std::ostream &operator<<(std::ostream&,
const SCVector3 &);
143 #ifdef INLINE_FUNCTIONS
144 #include <math/scmat/vector3_i.h>