Implementation of functions for internal implementation of plotting.
More...
#include "func_sketch/plotter/plotting_util.h"
#include <cassert>
#include <cmath>
#include <opencv2/imgproc.hpp>
#include "func_sketch/common_types.h"
#include "func_sketch/exceptions.h"
Go to the source code of this file.
|
| cv::Scalar | func_sketch::plotter::convert_color (const RGBColor &color) |
| | Convert a color from RGBColor to cv::Scalar.
|
| cv::Point | func_sketch::plotter::convert_position (const Point &position, const PlotRange &range, const PlotConfig &config, int left_margin, const cv::MatSize &size) |
| | Convert a position from plot coordinates to image coordinates.
|
| cv::Point | func_sketch::plotter::convert_position_with_shift (const Point &position, const PlotRange &range, const PlotConfig &config, int left_margin, const cv::MatSize &size, int shift) |
| | Convert a position from plot coordinates to image coordinates with shift.
|
| void | func_sketch::plotter::write_line (Image &image, const Point &start_point, const Point &end_point, const cv::Scalar &color, int line_width, const PlotRange &range, const PlotConfig &config, int left_margin) |
| | Write a line on an image.
|
| bool | func_sketch::plotter::try_clamp_infinity (Point &point, const PlotRange &range) |
| | Try to clamp a point with infinity to the range.
|
| Point | func_sketch::plotter::compute_intersection_with_vertical_line (const Point &point1, const Point &point2, Real x_value) |
| | Compute the intersection of a line segment with a vertical line.
|
| Point | func_sketch::plotter::compute_intersection_with_horizontal_line (const Point &point1, const Point &point2, Real y_value) |
| | Compute the intersection of a line segment with a horizontal line.
|
| Point | func_sketch::plotter::compute_intersection_with_range (const Point &point_in_range, const Point &point_out_of_range, const PlotRange &range) |
| | Compute the intersection of a line segment with the boundary of the plot range.
|
Implementation of functions for internal implementation of plotting.
Definition in file plotting_util.cpp.
◆ convert_color()
| cv::Scalar func_sketch::plotter::convert_color |
( |
const RGBColor & | color | ) |
|
|
nodiscard |
Convert a color from RGBColor to cv::Scalar.
- Parameters
-
| [in] | color | Color to convert. |
- Returns
- Converted color.
- Note
- This function assumes that the image is in RGB format, not BGR format as in default of OpenCV.
Definition at line 32 of file plotting_util.cpp.
◆ convert_position()
| cv::Point func_sketch::plotter::convert_position |
( |
const Point & | position, |
|
|
const PlotRange & | range, |
|
|
const PlotConfig & | config, |
|
|
int | left_margin, |
|
|
const cv::MatSize & | size ) |
|
nodiscard |
Convert a position from plot coordinates to image coordinates.
- Parameters
-
| [in] | position | Position in plot coordinates. |
| [in] | range | Range of plots. |
| [in] | config | Configuration of plots. |
| [in] | left_margin | Left margin of plots in pixels. (This value is used over the value in config because tuning of the left margin is needed.) |
| [in] | size | Size of the image. |
- Returns
- Converted position in image coordinates.
Definition at line 37 of file plotting_util.cpp.
◆ convert_position_with_shift()
| cv::Point func_sketch::plotter::convert_position_with_shift |
( |
const Point & | position, |
|
|
const PlotRange & | range, |
|
|
const PlotConfig & | config, |
|
|
int | left_margin, |
|
|
const cv::MatSize & | size, |
|
|
int | shift ) |
|
nodiscard |
Convert a position from plot coordinates to image coordinates with shift.
- Parameters
-
| [in] | position | Position in plot coordinates. |
| [in] | range | Range of plots. |
| [in] | config | Configuration of plots. |
| [in] | left_margin | Left margin of plots in pixels. (This value is used over the value in config because tuning of the left margin is needed.) |
| [in] | size | Size of the image. |
| [in] | shift | Number of fractional bits in the image coordinates. |
- Returns
- Converted position in image coordinates.
Definition at line 72 of file plotting_util.cpp.
◆ write_line()
| void func_sketch::plotter::write_line |
( |
Image & | image, |
|
|
const Point & | start_point, |
|
|
const Point & | end_point, |
|
|
const cv::Scalar & | color, |
|
|
int | line_width, |
|
|
const PlotRange & | range, |
|
|
const PlotConfig & | config, |
|
|
int | left_margin ) |
Write a line on an image.
- Parameters
-
| [out] | image | Image to write on. |
| [in] | start_point | Starting point of the line. |
| [in] | end_point | Ending point of the line. |
| [in] | color | Color of the line. |
| [in] | line_width | Width of the line. |
| [in] | range | Range of plots. |
| [in] | config | Configuration of plots. |
| [in] | left_margin | Left margin of plots in pixels. (This value is used over the value in config because tuning of the left margin is needed.) |
Definition at line 101 of file plotting_util.cpp.
◆ try_clamp_infinity()
| bool func_sketch::plotter::try_clamp_infinity |
( |
Point & | point, |
|
|
const PlotRange & | range ) |
|
nodiscard |
Try to clamp a point with infinity to the range.
- Parameters
-
| [in,out] | point | Point to clamp. |
| [in] | range | Range to clamp the point to. |
- Return values
-
| true | The point was clamped or the point was finite. |
| false | The point could not be clamped because it was infinite in both coordinates. |
- Note
- This function does not check for NaN values.
Definition at line 114 of file plotting_util.cpp.
◆ compute_intersection_with_vertical_line()
| Point func_sketch::plotter::compute_intersection_with_vertical_line |
( |
const Point & | point1, |
|
|
const Point & | point2, |
|
|
Real | x_value ) |
Compute the intersection of a line segment with a vertical line.
- Parameters
-
| [in] | point1 | First point of the line segment. |
| [in] | point2 | Second point of the line segment. |
| [in] | x_value | X-coordinate of the vertical line. |
- Returns
- Intersection point of the line segment with the vertical line.
Definition at line 137 of file plotting_util.cpp.
◆ compute_intersection_with_horizontal_line()
| Point func_sketch::plotter::compute_intersection_with_horizontal_line |
( |
const Point & | point1, |
|
|
const Point & | point2, |
|
|
Real | y_value ) |
Compute the intersection of a line segment with a horizontal line.
- Parameters
-
| [in] | point1 | First point of the line segment. |
| [in] | point2 | Second point of the line segment. |
| [in] | y_value | Y-coordinate of the horizontal line. |
- Returns
- Intersection point of the line segment with the horizontal line.
Definition at line 153 of file plotting_util.cpp.
◆ compute_intersection_with_range()
| Point func_sketch::plotter::compute_intersection_with_range |
( |
const Point & | point_in_range, |
|
|
const Point & | point_out_of_range, |
|
|
const PlotRange & | range ) |
|
nodiscard |
Compute the intersection of a line segment with the boundary of the plot range.
- Parameters
-
| [in] | point_in_range | Point inside the range. |
| [in] | point_out_of_range | Point outside the range. |
| [in] | range | Range of plots. |
- Returns
- Intersection point of the line segment with the range.
- Note
- This function assumes that all coordinates are finite and that the line segment intersects with the boundary of the range.
Definition at line 161 of file plotting_util.cpp.