Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • leggett/acts-core
  • adye/acts-core
  • xju/acts-core
  • corentin/acts-core
  • keli/acts-core
  • gli/acts-core
  • xai/acts-core
  • bschlag/acts-core
  • berkeleylab/acts/acts-core
  • emoyse/acts-core
  • smh/acts-core
  • pagessin/acts-core
  • chamont/acts-core
  • sroe/a-common-tracking-sw
  • calaf/a-common-tracking-sw
  • hgraslan/acts-core
16 results
Show changes
Commits on Source (2)
......@@ -40,7 +40,13 @@ public:
/// @param haley halflength in Y
RectangleBounds(double halex, double haley);
~RectangleBounds() override;
/// Constructor with explicit min and max vertex
///
/// @param vmin Minimum vertex
/// @param vmax Maximum vertex
RectangleBounds(const Vector2D& vmin, const Vector2D& vmax);
~RectangleBounds() override = default;
RectangleBounds*
clone() const final;
......@@ -90,20 +96,31 @@ public:
double
halflengthY() const;
/// Get the min vertex defining the bounds
/// @return The min vertex
const Vector2D&
min() const;
/// Get the max vertex defining the bounds
/// @return The max vertex
const Vector2D&
max() const;
private:
double m_halfX, m_halfY;
Vector2D m_min;
Vector2D m_max;
};
inline double
RectangleBounds::halflengthX() const
{
return m_halfX;
return std::abs(m_max.x() - m_min.x()) * 0.5;
}
inline double
RectangleBounds::halflengthY() const
{
return m_halfY;
return std::abs(m_max.y() - m_min.y()) * 0.5;
}
inline SurfaceBounds::BoundsType
......@@ -112,4 +129,16 @@ RectangleBounds::type() const
return SurfaceBounds::Rectangle;
}
} // namespace
\ No newline at end of file
inline const Vector2D&
RectangleBounds::min() const
{
return m_min;
}
inline const Vector2D&
RectangleBounds::max() const
{
return m_max;
}
} // namespace Acts
......@@ -18,11 +18,15 @@
#include <iostream>
Acts::RectangleBounds::RectangleBounds(double halex, double haley)
: m_halfX(std::abs(halex)), m_halfY(std::abs(haley))
: m_min(-halex, -haley), m_max(halex, haley)
{
}
Acts::RectangleBounds::~RectangleBounds() = default;
Acts::RectangleBounds::RectangleBounds(const Vector2D& vmin,
const Vector2D& vmax)
: m_min(vmin), m_max(vmax)
{
}
Acts::RectangleBounds*
Acts::RectangleBounds::clone() const
......@@ -34,8 +38,7 @@ std::vector<TDD_real_t>
Acts::RectangleBounds::valueStore() const
{
std::vector<TDD_real_t> values(RectangleBounds::bv_length);
values[RectangleBounds::bv_halfX] = halflengthX();
values[RectangleBounds::bv_halfY] = halflengthY();
values = {m_min.x(), m_min.y(), m_max.x(), m_max.y()};
return values;
}
......@@ -43,27 +46,22 @@ bool
Acts::RectangleBounds::inside(const Acts::Vector2D& lpos,
const Acts::BoundaryCheck& bcheck) const
{
return bcheck.isInside(lpos,
Vector2D(-halflengthX(), -halflengthY()),
Vector2D(halflengthX(), halflengthY()));
return bcheck.isInside(lpos, m_min, m_max);
}
double
Acts::RectangleBounds::distanceToBoundary(const Acts::Vector2D& lpos) const
{
return BoundaryCheck(true).distance(lpos,
Vector2D(-halflengthX(), -halflengthY()),
Vector2D(halflengthX(), halflengthY()));
return BoundaryCheck(true).distance(lpos, m_min, m_max);
}
std::vector<Acts::Vector2D>
Acts::RectangleBounds::vertices() const
{
// counter-clockwise starting from bottom-right corner
return {{halflengthX(), -halflengthY()},
{halflengthX(), halflengthY()},
{-halflengthX(), halflengthY()},
{-halflengthX(), -halflengthY()}};
return {
{m_max.x(), m_min.y()}, m_max, {m_min.x(), m_max.y()}, m_min,
};
}
const Acts::RectangleBounds&
......@@ -78,8 +76,10 @@ Acts::RectangleBounds::toStream(std::ostream& sl) const
{
sl << std::setiosflags(std::ios::fixed);
sl << std::setprecision(7);
sl << "Acts::RectangleBounds: (halflengthX, halflengthY) = "
sl << "Acts::RectangleBounds: (hlX, hlY) = "
<< "(" << halflengthX() << ", " << halflengthY() << ")";
sl << "\n(lower left, upper right):\n";
sl << m_min.transpose() << "\n" << m_max.transpose();
sl << std::setprecision(-1);
return sl;
}
......@@ -87,6 +87,10 @@ namespace Test {
RectangleBounds rect(halfX, halfY);
BOOST_CHECK_EQUAL(rect.halflengthX(), 10.);
BOOST_CHECK_EQUAL(rect.halflengthY(), 5.);
CHECK_CLOSE_ABS(rect.min(), Vector2D(-halfX, -halfY), 1e-6);
CHECK_CLOSE_ABS(rect.max(), Vector2D(halfX, halfY), 1e-6);
const std::vector<Vector2D> coords
= {{10., -5.}, {10., 5.}, {-10., 5.}, {-10., -5.}};
// equality, ensure ordering is ok
......