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]);
40 unsigned int maxi = 0;
41 if (std::abs(v[1]) > std::abs(v[0])) maxi = 1;
42 if (std::abs(v[2]) > std::abs(v[maxi])) maxi = 2;
43 if (std::abs(v[maxi]) < .0001) {
46 Vector3D ret = get_ones_vector_d<3>();
47 ret[maxi] = (-v[(maxi + 1) % 3] - v[(maxi + 2) % 3]) / v[maxi];
57 return std::accumulate(ps.begin(), ps.end(), get_zero_vector_d<3>()) /
68 for (
unsigned int i = 0; i < ps.size(); i++) {
77 IMPALGEBRA_END_NAMESPACE
Various general useful macros for IMP.
double get_squared_distance(const VectorD< D > &v1, const VectorD< D > &v2)
compute the squared distance between two vectors
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Returns the vector product (cross product) of two vectors.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
double get_radius_of_gyration(const Vector3Ds &ps)
Return the radius of gyration of a set of points.
Exception definitions and assertions.
Vector3D get_centroid(const Vector3Ds &ps)
Returns the centroid of a set of vectors.
Vector3D get_orthogonal_vector(const Vector3D &v)
Return a vector that is perpendicular to the given vector.