30 double x(
void)
const {
return P.
x(); }
31 double y(
void)
const {
return P.
y(); }
32 double z(
void)
const {
return P.
z(); }
33 double norm()
const {
return std::sqrt(this->
normSq()); }
34 double normSq()
const {
return P[0] *
P[0] +
P[1] *
P[1] +
P[2] *
P[2]; }
107 operator double *() {
return P; }
108 void print(
const std::string &name =
"")
const
118 if((
P[0] >=
P[1]) && (
P[0] >=
P[2])) {
122 else if((
P[1] >=
P[0]) && (
P[1] >=
P[2])) {
135 for(
int i = 0; i < 3; i++) {
P[i] += (a *
y[i]); }
138 operator std::array<double, 3>()
const {
return {{
P[0],
P[1],
P[2]}}; }
143 return a.
x() * b.
x() + a.
y() * b.
y() + a.
z() * b.
z();
153 -(a.
x() * b.
z() - b.
x() * a.
z()),
154 a.
x() * b.
y() - b.
x() * a.
y());
159 double cosTheta =
dot(a, b);
161 return atan2(sinTheta, cosTheta);
167 double cosTheta =
dot(a, b);
169 return atan2(sinTheta, cosTheta);
174 return SVector3(v[0] * m, v[1] * m, v[2] * m);
179 return SVector3(v[0] * m, v[1] * m, v[2] * m);
184 return SVector3(v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]);
189 return SVector3(a[0] + b[0], a[1] + b[1], a[2] + b[2]);
194 return SPoint3(a[0] + b[0], a[1] + b[1], a[2] + b[2]);
199 return SVector3(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
204 return SPoint3(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
209 return SVector3(-a[0], -a[1], -a[2]);
215 if(dir[1] != 0.0 && dir[2] != 0.0) {
216 dir1 =
SVector3(1.0, 0.0, -dir[0] / dir[2]);
219 -(dir[0] * dir[0] + dir[2] * dir[2]) / (dir[1] * dir[2]), 1.0);
221 else if(dir[0] != 0.0 && dir[2] != 0.0) {
222 dir1 =
SVector3(-dir[1] / dir[0], 1.0, 0.0);
223 dir2 =
SVector3(1.0, dir[1] / dir[0],
224 -(dir[1] * dir[1] + dir[0] * dir[0]) / (dir[0] * dir[2]));
226 else if(dir[0] != 0.0 && dir[1] != 0.0) {
227 dir1 =
SVector3(0.0, -dir[2] / dir[1], 1.0);
228 dir2 =
SVector3(-(dir[1] * dir[1] + dir[2] * dir[2]) / (dir[0] * dir[1]),
229 1.0, dir[2] / dir[1]);
231 else if(dir[0] == 0.0 && dir[1] == 0.0) {
235 else if(dir[1] == 0.0 && dir[2] == 0.0) {
239 else if(dir[0] == 0.0 && dir[2] == 0.0) {
262 if(fabs(normal[0]) > fabs(normal[1]))