8 #ifndef IMPALGEBRA_VECTOR_3D_H
9 #define IMPALGEBRA_VECTOR_3D_H
20 IMPALGEBRA_BEGIN_NAMESPACE
32 return Vector3D(p1[1] * p2[2] - p1[2] * p2[1], p1[2] * p2[0] - p1[0] * p2[2],
33 p1[0] * p2[1] - p1[1] * p2[0]);
52 unsigned int maxi = 0;
53 if (std::abs(v[1]) > std::abs(v[0])) maxi = 1;
54 if (std::abs(v[2]) > std::abs(v[maxi])) maxi = 2;
55 if (std::abs(v[maxi]) < .0001) {
58 Vector3D ret = get_ones_vector_d<3>();
59 ret[maxi] = (-v[(maxi + 1) % 3] - v[(maxi + 2) % 3]) / v[maxi];
69 return std::accumulate(ps.begin(), ps.end(), get_zero_vector_d<3>()) /
80 for (
unsigned int i = 0; i < ps.size(); i++) {
89 IMPALGEBRA_END_NAMESPACE
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
Compute the squared distance between two vectors.
Exception definitions and assertions.
A more IMP-like version of the std::vector.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Return the vector product (cross product) of two vectors.
double get_radius_of_gyration(const Vector3Ds &ps)
Return the radius of gyration of a set of points.
Vector3D get_centroid(const Vector3Ds &ps)
Return the centroid of a set of vectors.
Vector3D get_orthogonal_vector(const Vector3D &v)
Return a vector that is perpendicular to the given vector.
Various general useful macros for IMP.