28 #ifndef _math_scmat_vector3_h
29 #define _math_scmat_vector3_h
34 #include <util/misc/exenv.h>
35 #include <util/keyval/keyval.h>
51 _v[0] = p[0]; _v[1] = p[1]; _v[2] = p[2];
53 SCVector3(
double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
55 _v[0] = x; _v[1] = y; _v[2] = z;
58 _v[0] = p._v[0]; _v[1] = p._v[1]; _v[2] = p._v[2];
66 void operator = (
const double *x) {
76 void operator = (
double d) { _v[0] = d; _v[1] = d; _v[2] = d; }
87 void operator *= (
double m) { _v[0] *= m; _v[1] *= m; _v[2] *= m; }
90 result._v[0] = _v[0] + v._v[0];
91 result._v[1] = _v[1] + v._v[1];
92 result._v[2] = _v[2] + v._v[2];
97 result._v[0] = _v[0] - v._v[0];
98 result._v[1] = _v[1] - v._v[1];
99 result._v[2] = _v[2] - v._v[2];
103 return _v[0]*v._v[0] + _v[1]*v._v[1] + _v[2]*v._v[2]; }
107 void spherical_coord(
double theta,
double phi,
109 void spherical_to_cartesian(
SCVector3&cart)
const;
110 double maxabs()
const;
114 double norm()
const {
return sqrt(this->dot(*
this)); }
115 double& elem(
int xyz) {
return _v[xyz]; }
116 const double& elem(
int xyz)
const {
return _v[xyz]; }
117 double& operator [] (
int i) {
return _v[i]; }
118 const double& operator [] (
int i)
const {
return _v[i]; }
119 double& operator () (
int i) {
return _v[i]; }
120 const double& operator () (
int i)
const {
return _v[i]; }
121 const double* data()
const {
return _v; }
122 double* data() {
return _v; }
123 double& x() {
return _v[0]; }
124 double& y() {
return _v[1]; }
125 double& z() {
return _v[2]; }
126 const double& x()
const {
return _v[0]; }
127 const double& y()
const {
return _v[1]; }
128 const double& z()
const {
return _v[2]; }
129 double& r() {
return _v[0]; }
130 double& theta() {
return _v[1]; }
131 double& phi() {
return _v[2]; }
132 const double& r()
const {
return _v[0]; }
133 const double& theta()
const {
return _v[1]; }
134 const double& phi()
const {
return _v[2]; }
146 #ifdef INLINE_FUNCTIONS
147 #include <math/scmat/vector3_i.h>