ellipsoid_tree 0.1.0
Exact intersection tests for ellipsoids and friends
Loading...
Searching...
No Matches
plot2d.hpp File Reference

Build a 2D figure from the library's geometric objects and trees and write it as SVG or PNG. More...

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <limits>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <Eigen/Dense>
#include <Eigen/Eigenvalues>
#include "ellipsoid_tree/geometry.hpp"
#include "ellipsoid_tree/object_tree.hpp"
#include "ellipsoid_tree/kd_tree.hpp"
#include "ellipsoid_tree/simplex_mesh.hpp"
#include "ellipsoid_tree/detail/raster2d.hpp"

Classes

struct  ellipsoid_tree::Color
 An RGBA color with components in [0, 1]. More...
 
struct  ellipsoid_tree::Style
 Stroke and fill styling for a drawn primitive. More...
 
struct  ellipsoid_tree::RenderedImage
 An in-memory RGB raster produced by Plot2D::render_rgb. More...
 
class  ellipsoid_tree::Plot2D
 A world-coordinate 2D scene of drawable primitives with SVG and PNG writers. More...
 
struct  ellipsoid_tree::DrawTreeOptions
 Options controlling what draw_tree renders and how. More...
 
struct  ellipsoid_tree::DrawKDTreeOptions
 Options controlling what draw_kdtree renders and how. More...
 
struct  ellipsoid_tree::FieldOptions
 Options controlling how draw_cg1_field maps field values to colors. More...
 

Namespaces

namespace  ellipsoid_tree
 

Enumerations

enum class  ellipsoid_tree::TextAnchor { ellipsoid_tree::start , ellipsoid_tree::middle , ellipsoid_tree::end }
 Horizontal text alignment relative to the anchor point. More...
 

Functions

Color ellipsoid_tree::colormap_viridis (double t)
 The viridis colormap, t in [0, 1].
 
void ellipsoid_tree::draw_tree (Plot2D &fig, const EllipsoidTree &T, DrawTreeOptions opts=DrawTreeOptions())
 Draw an EllipsoidTree's objects and its AABB node hierarchy.
 
void ellipsoid_tree::draw_tree (Plot2D &fig, const BoxTree &T, DrawTreeOptions opts=DrawTreeOptions())
 Draw a BoxTree's objects and its AABB node hierarchy.
 
void ellipsoid_tree::draw_tree (Plot2D &fig, const BallTree &T, DrawTreeOptions opts=DrawTreeOptions())
 Draw a BallTree's objects and its AABB node hierarchy.
 
void ellipsoid_tree::draw_tree (Plot2D &fig, const SimplexTree &T, DrawTreeOptions opts=DrawTreeOptions())
 Draw a SimplexTree's objects and its AABB node hierarchy.
 
void ellipsoid_tree::draw_elements (Plot2D &fig, const EllipsoidTree &T, const std::vector< int > &inds, const Style &style)
 Draw only the listed elements (e.g. the results of a collision query).
 
void ellipsoid_tree::draw_elements (Plot2D &fig, const BoxTree &T, const std::vector< int > &inds, const Style &style)
 Draw the listed box elements in the given style.
 
void ellipsoid_tree::draw_elements (Plot2D &fig, const BallTree &T, const std::vector< int > &inds, const Style &style)
 Draw the listed ball elements in the given style.
 
void ellipsoid_tree::draw_elements (Plot2D &fig, const SimplexTree &T, const std::vector< int > &inds, const Style &style)
 Draw the listed simplex elements in the given style.
 
void ellipsoid_tree::draw_batches (Plot2D &fig, const EllipsoidTree &T, const std::vector< std::vector< int > > &batches, double fill_alpha=0.3, double stroke_width=1.3)
 Ellipsoids colored by batch (from pick_ellipsoid_batches).
 
void ellipsoid_tree::draw_kdtree (Plot2D &fig, const KDTree &T, DrawKDTreeOptions opts=DrawKDTreeOptions())
 Draw a kd-tree: its recursive splitting lines and the stored points.
 
void ellipsoid_tree::draw_cg1_field (Plot2D &fig, const SimplexMesh &mesh, const Eigen::Ref< const Eigen::VectorXd > &vertex_values, FieldOptions opts=FieldOptions())
 Render a CG1 nodal field on a 2D SimplexMesh through the viridis colormap.
 

Detailed Description

Build a 2D figure from the library's geometric objects and trees and write it as SVG or PNG.

Optional 2D visualization: build a figure from the library's geometric objects and trees, then write it as an SVG (vector; ellipses keep their true center/axes/rotation as readable XML). This header is deliberately NOT included by the ellipsoid_tree.hpp umbrella — include it only if you want it. It has no dependencies beyond the library itself.

Plot2D fig; fig.add(ellipsoid, tau, Style{...}); draw_tree(fig, ellipsoid_tree, {}); // objects + AABB hierarchy draw_kdtree(fig, kd); // splitting-line partition draw_batches(fig, ellipsoid_tree, batches); // color by batch fig.save_svg("figure.svg"); // axes with physical extents

All draw functions require dim() == 2 and throw std::invalid_argument otherwise. A PNG raster backend is planned as a follow-up.