BsLineSegment3.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. #include "BsVector3.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Represents a line segment in three dimensional space defined by
  8. * a start and an end point.
  9. */
  10. class BS_UTILITY_EXPORT LineSegment3
  11. {
  12. public:
  13. LineSegment3();
  14. LineSegment3(const Vector3& start, const Vector3& end);
  15. /**
  16. * @brief Find the nearest point on the line segment and the provided ray.
  17. *
  18. * @return Set of nearest points and distance from the points. First
  19. * nearest point is a point along the ray, while the second is along the
  20. * line segment.
  21. *
  22. * @note If segment and ray are parallel the set of points at the segment origin are returned.
  23. */
  24. std::pair<std::array<Vector3, 2>, float> getNearestPoint(const Ray& ray) const;
  25. /**
  26. * @brief Returns the starting point of the line segment.
  27. */
  28. const Vector3& getStart() const { return mStart; }
  29. /**
  30. * @brief Returns the ending point of the line segment.
  31. */
  32. const Vector3& getEnd() const { return mEnd; }
  33. private:
  34. Vector3 mStart, mEnd;
  35. };
  36. }