IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Triangle3D.h
Go to the documentation of this file.
1/**
2 * \file IMP/algebra/Triangle3D.h
3 * \brief Represent a triangle in 3D
4 *
5 * Copyright 2007-2026 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"
15#include <iostream>
16#include <cereal/access.hpp>
17#include "constants.h"
18
19IMPALGEBRA_BEGIN_NAMESPACE
20
21//! Represent a triangle in 3D
22/** \geometry */
23class 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
37private:
38 Vector3D p_[3];
39
40 friend class cereal::access;
41
42 template<class Archive> void serialize(Archive &ar) {
43 ar(p_[0], p_[1], p_[2]);
44 }
45};
46
48
49//! Return the largest triangle defined by 3 points from the input
50/** \see Triangle3D */
51IMPALGEBRAEXPORT Triangle3D get_largest_triangle(const Vector3Ds &points);
52
53//! Return a transformation between two triangles
54IMPALGEBRAEXPORT Transformation3D
56 Triangle3D second_tri);
57//! Return true if the three points are co-linear
58IMPALGEBRAEXPORT bool get_are_colinear(const Vector3D &p1, const Vector3D &p2,
59 const Vector3D &p3);
60
61IMPALGEBRA_END_NAMESPACE
62
63#endif /* IMPALGEBRA_TRIANGLE_3D_H */
Base class for geometric types.
A reference frame in 3D.
Simple 3D transformation class.
Simple 3D vector class.
Various useful constants.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Simple 3D transformation class.
Represent a triangle in 3D.
Definition Triangle3D.h:23
Triangle3D(const Vector3D &p1, const Vector3D &p2, const Vector3D &p3)
The passed points must not be colinear.
const Vector3D & get_point(unsigned int i) const
Get the start=0/end=1 point of the segment.
Definition Triangle3D.h:29
Triangle3D get_largest_triangle(const Vector3Ds &points)
Return the largest triangle defined by 3 points from the input.
Transformation3D get_transformation_from_first_triangle_to_second(Triangle3D first_tri, Triangle3D second_tri)
Return a transformation between two triangles.
bool get_are_colinear(const Vector3D &p1, const Vector3D &p2, const Vector3D &p3)
Return true if the three points are co-linear.
IMP::Vector< Triangle3D > Triangle3Ds
Definition Triangle3D.h:47
Vector< VectorD< 3 > > Vector3Ds
Definition VectorD.h:409
VectorD< 3 > Vector3D
Definition VectorD.h:407
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
Definition types.h:46
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.