IMP  2.2.1
The Integrative Modeling Platform
Triangle3D.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/Triangle3D.h
3  * \brief simple implementation of a triangle in 3D
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPALGEBRA_TRIANGLE_3D_H
9 #define IMPALGEBRA_TRIANGLE_3D_H
10 
11 #include "Vector3D.h"
12 #include "Transformation3D.h"
13 #include "ReferenceFrame3D.h"
14 #include "algebra_macros.h"
15 #include "GeometricPrimitiveD.h"
16 #include <iostream>
17 #include "constants.h"
18 
19 IMPALGEBRA_BEGIN_NAMESPACE
20 /**
21  \geometry
22  */
23 class IMPALGEBRAEXPORT Triangle3D : public GeometricPrimitiveD<3> {
24  public:
25  Triangle3D() {}
26  //! The passed points must not be colinear
27  Triangle3D(const Vector3D &p1, const Vector3D &p2, const Vector3D &p3);
28  //! Get the start=0/end=1 point of the segment
29  const Vector3D &get_point(unsigned int i) const {
30  IMP_USAGE_CHECK(i < 3, "invalid point index");
31  return p_[i];
32  }
33  IMP_SHOWABLE_INLINE(Triangle3D, out << "(" << p_[0] << ", " << p_[1] << ", "
34  << p_[2] << ")");
35  Floats get_edge_lengths() const;
36 
37  private:
38  Vector3D p_[3];
39 };
40 
42 
43 //! Return the largest triangle defined by 3 points from the input
44 /** See Triangle3D */
45 IMPALGEBRAEXPORT Triangle3D get_largest_triangle(const Vector3Ds &points);
46 
47 //! Return a transformation between two triangles
48 IMPALGEBRAEXPORT Transformation3D
50  Triangle3D second_tri);
51 //! Return true if the three points are co-linear
52 IMPALGEBRAEXPORT bool get_are_colinear(const Vector3D &p1, const Vector3D &p2,
53  const Vector3D &p3);
54 
55 IMPALGEBRA_END_NAMESPACE
56 
57 #endif /* IMPALGEBRA_TRIANGLE_3D_H */
Basic types used by IMP.
Simple 3D transformation class.
Triangle3D get_largest_triangle(const Vector3Ds &points)
Return the largest triangle defined by 3 points from the input.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Transformation3D get_transformation_from_first_triangle_to_second(Triangle3D first_tri, Triangle3D second_tri)
Return a transformation between two triangles.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
bool get_are_colinear(const Vector3D &p1, const Vector3D &p2, const Vector3D &p3)
Return true if the three points are co-linear.
Various useful constants.
Simple 3D transformation class.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Simple 3D vector class.
Simple 3D rotation class.
const Vector3D & get_point(unsigned int i) const
Get the start=0/end=1 point of the segment.
Definition: Triangle3D.h:29
Various important macros for implementing geometry.