2#include "tools/Vector3d.h"
16Vector3d::Vector3d(
double x,
double y,
double z)
21void Vector3d::set(
double nx,
double ny,
double nz)
28void Vector3d::setComponent(
int i,
double val)
44void Vector3d::setZero()
51 set(other.x, other.y, other.z);
54void Vector3d::scale(
double s)
61void Vector3d::normalize()
72 return a.x * b.x + a.y * b.y + a.z * b.z;
75double Vector3d::length()
77 return sqrt(x * x + y * y + z * z);
80bool Vector3d::sameValues(
Vector3d other)
82 return (x == other.x) && (y == other.y) && (z == other.z);
101 result.set(a.y * b.z - a.z * b.y,
102 a.z * b.x - a.x * b.z,
103 a.x * b.y - a.y * b.x);
108 int k = largestAbsComponent(v) - 1;
114 result.setComponent(k, 1.0);
115 cross(v, result, result);
119int Vector3d::largestAbsComponent(
Vector3d v)
121 double xAbs = fabs(v.x);
122 double yAbs = fabs(v.y);
123 double zAbs = fabs(v.z);