15 auto distFromOrigin = p - origin;
17 auto projectionFromOrigin = (distFromOrigin * direction) /
length();
20 if (projectionFromOrigin >
length()) {
21 return glm::length(glm::vec3(p - (origin + direction)));
24 else if (projectionFromOrigin < 0.0f) {
25 return glm::length(glm::vec3(p - origin));
29 auto closestPoint = origin + glm::normalize(glm::vec3(direction)) * projectionFromOrigin;
30 return glm::length(glm::vec3(p - closestPoint));
36 return glm::length(glm::vec3(direction));
44 auto distFromOrigin = p - origin;
45 auto projectionFromOrigin = (distFromOrigin * direction) /
length();
46 auto closestPoint = origin + glm::normalize(glm::vec3(direction)) * projectionFromOrigin;
47 return glm::normalize(glm::vec3(closestPoint - p));
55 return glm::vec3{ direction.
y(), -direction.
x(), direction.
z()};
63 return origin + direction;
Definition: Foundations.h:230
Definition: Foundations.h:187
DeltaSpace normal(Position p) const
Returns the normal always pointing to the vector.
Definition: Segment.h:43
const Position & getEnd() const
Definition: Segment.h:62
float length() const
Definition: Segment.h:35
DeltaSpace normal() const
Returns the clockwise normal.
Definition: Segment.h:54
const DeltaSpace & getDirection() const
Definition: Segment.h:66
Segment(Position p1, Position p2)
Definition: Segment.h:12
const Position & getOrigin() const
Definition: Segment.h:58
float distance(Position p) const
Definition: Segment.h:14
float x() const
Definition: Foundations.h:20
float z() const
Definition: Foundations.h:28
float y() const
Definition: Foundations.h:24
Definition: Cinematicable.h:9