BsLineSegment3.h 1.1 KB

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