feat(viz): surface_plot_3d real (ImPlot3D) + scatter_3d nuevo
surface_plot_3d (v2.0.0): quita el STUB. API basada en SurfacePlot3DConfig (z[nx*ny] row-major + ranges X/Y) que delega en ImPlot3D::PlotSurface. Las coordenadas X/Y por vertice se generan internamente desde [x_min, x_max] x [y_min, y_max]. scatter_3d (v1.0.0): nuevo primitivo. Scatter 3D con tamano y color opcionales por punto via ImPlot3DSpec::MarkerSizes / MarkerFillColors. Util para PCA / clustering / nubes de puntos sinteticas. Ambos namespace fn::, kind component, purity pure. Orbit / zoom / pan los aporta ImPlot3D nativo. Issue 0028.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "viz/scatter_3d.h"
|
||||
|
||||
#include "imgui.h"
|
||||
#include "implot3d.h"
|
||||
|
||||
namespace fn {
|
||||
|
||||
void scatter_3d(const char* title, const Scatter3DConfig& cfg) {
|
||||
if (!cfg.xs || !cfg.ys || !cfg.zs || cfg.n < 1) {
|
||||
ImGui::BeginGroup();
|
||||
ImGui::TextDisabled("%s", title ? title : "##scatter_3d");
|
||||
ImGui::TextWrapped("scatter_3d: necesita xs, ys, zs != nullptr y n >= 1 (recibido n=%d)",
|
||||
cfg.n);
|
||||
ImGui::EndGroup();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImPlot3D::BeginPlot(title, cfg.size)) {
|
||||
ImPlot3D::SetupAxes("x", "y", "z");
|
||||
|
||||
// ImPlot3DSpec::MarkerSizes / MarkerFillColors esperan punteros no
|
||||
// const; los arrays de cfg vienen como const*. Como ImPlot3D solo los
|
||||
// lee, hacemos un const_cast acotado a esta llamada.
|
||||
ImPlot3DSpec spec;
|
||||
if (cfg.sizes) spec.MarkerSizes = const_cast<float*>(cfg.sizes);
|
||||
if (cfg.colors) spec.MarkerFillColors = const_cast<ImU32*>(cfg.colors);
|
||||
|
||||
ImPlot3D::PlotScatter("##points", cfg.xs, cfg.ys, cfg.zs, cfg.n, spec);
|
||||
ImPlot3D::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fn
|
||||
Reference in New Issue
Block a user