UAV Simulator
|
Represents a sequence of connected path segments (e.g., straight lines, arcs). More...
#include <path.h>
Public Member Functions | |
void | addStraightSegment (const easy3d::vec3 &start, const easy3d::vec3 &end) |
Adds a straight line segment to the path. | |
std::vector< easy3d::vec3 > | generateWaypoints (float spacing) const |
Generates a list of evenly spaced waypoints along the entire path. | |
void | draw (easy3d::Viewer &viewer) const |
Renders the full path in the viewer. | |
Private Attributes | |
std::vector< std::unique_ptr< LineSegment > > | segments |
The sequence of segments (e.g., lines, arcs) that make up the full path. | |
Represents a sequence of connected path segments (e.g., straight lines, arcs).
This class allows the construction of a path using various types of segments and supports generating discrete waypoints and visualizing the full path.
void Path::addStraightSegment | ( | const easy3d::vec3 & | start, |
const easy3d::vec3 & | end | ||
) |
Adds a straight line segment to the path.
start | The 3D start point of the segment. |
end | The 3D end point of the segment. |
This function creates a new LineSegment instance and appends it to the internal list of path segments.
start | Start position of the line segment in 3D space. |
end | End position of the line segment in 3D space. |
void Path::draw | ( | easy3d::Viewer & | viewer | ) | const |
Renders the full path in the viewer.
Renders the entire path as a sequence of line segments in the viewer.
This method draws all path segments currently stored in the path. Each segment handles its own rendering logic (e.g., line, arc).
viewer | Reference to the Easy3D viewer used for rendering. |
This method converts the path into a set of line segments using sampled waypoints and sends the data to an Easy3D LinesDrawable
for visualization.
viewer | Reference to the Easy3D viewer instance. |
std::vector< easy3d::vec3 > Path::generateWaypoints | ( | float | spacing | ) | const |
Generates a list of evenly spaced waypoints along the entire path.
Generates waypoints along all segments in the path.
spacing | Distance (in world units) between consecutive waypoints. |
This method queries each segment in the path to compute evenly spaced waypoints, then aggregates them into a single list.
spacing | Desired distance between consecutive waypoints. |
|
private |
The sequence of segments (e.g., lines, arcs) that make up the full path.