Skip to content

Point Clouds

Point clouds are one of the core structures in Polyscope. In addition to simply displaying the points, Polyscope can show any number of scalar, vector, or color quantities associated with the points.

As always, try clicking on a point to see the data associated with that point.

point_cloud_demo

Registering a point cloud

Example: a point cloud of random points

#include "polyscope/point_cloud.h"

std::vector<glm::vec3> points;

// generate points
for (size_t i = 0; i < 3000; i++) {
  points.push_back(
      glm::vec3{polyscope::randomUnit() - .5, 
                polyscope::randomUnit() - .5, 
                polyscope::randomUnit() - .5});
}

// visualize!
polyscope::PointCloud* psCloud = polyscope::registerPointCloud("really great points", points);

// set some options
psCloud->setPointRadius(0.02);
psCloud->setPointRenderMode(polyscope::PointRenderMode::Quad);

// show
polyscope::show()

PointCloud* registerPointCloud(std::string name, const T& pointPositions)

Add a new point cloud structure to Polyscope.

  • pointPositions is the array of 3D point locations. The type should be adaptable to an array of float-valued 3-vectors. The length will be the number of points.

Note: the inner vector type of the input must be 3D dimensional, or you risk compiler errors, segfaults, or worse. If you want to register a 2D point cloud, registerPointCloud2D exists with the same signature. See 2D data.

As with all structures, there is also getPointCloud("name"), hasPointCloud("name"), and removePointCloud("name").

Updating a point cloud

The locations of the points in a point cloud can be updated with the member function updatePointPositions(newPositions). All quantities will be preserved. Changing the number of points in the cloud is not supported, you will need to register a new cloud (perhaps with the same name to overwrite this one).

void PointCloud::updatePointPositions(const V& newPositions)

Update the point positions in a point cloud structure.

  • newPositions is the vector array of 3D point locations. The type should be adaptable to an array of float-valued 3-vectors. The length must be equal to the current number of points.

Note: updatePointPositions2D exists with the same signature. See 2D data.

Point render mode

By default, Polyscope renders point clouds with a sphere for each point. However, for large point clouds (for instance, > 500,000 points, or on low-end hardware), this sphere rendering may become prohibitively expensive and lead to a laggy interface. As an alternative, points can be rendered as a small quad per-point, which is more efficient (for instance, it renders in real-time with 20,000,000+ points on my mid-range GPU).

point render mode diagram

The PointRenderMode specifies which style is used:

  • PointRenderMode::Sphere a small sphere is drawn for each point (default)
  • PointRenderMode::Quad a small quad is drawn for each point
PointCloud* PointCloud::setPointRenderMode(PointRenderMode newVal)

Set the the rendering method used to draw each point. One of PointRenderMode::Sphere (default) or PointRenderMode::Quad.

There is also a corresponding getPointRenderMode().

Options

See structure management for options common to all structures such as enabling/disabling, transforms, and transparency.

Parameter Meaning Getter Setter Persistent?
point radius size of rendered points double getPointRadius() setPointRadius(double newVal, bool isRelative=true) yes
point color default color for point glm::vec3 getPointColor() setPointColor(glm::vec3 newVal) yes
point render mode how to draw points PointRenderMode getPointRenderMode() setPointRenderMode(PointRenderMode newVal) yes
material what material to use std::string getMaterial() setMaterial(std::string name) yes

(All setters return this to support chaining. Structure options return a generic structure pointer, so chain them last.)