A LiDAR sweep is a list of x, y, z points in no order. You can list sixty-four points in about 1.3 × 1089 orders, and a network must give the same answer for all of them. A shared MLP followed by a max does.
Pick a shape, then press Shuffle rows. The grey model reads the points as one long list. The warm model scores each point alone and keeps the largest value of each feature. Then drop points with the slider. After that we build, piece by piece, the scan, the voxel grid, neighbours, normals, PointNet, PointNet++ and registration.
You need Python with numpy arrays and what a dot product is. We build the rest from zero.
Illustrative toy. Both models are nearest-template classifiers on hand-made shapes, not trained networks. The grey one compares row i with template row i. The warm one uses PointNet's form: the same 24 features on every point, a max over points, then a comparison of the 24 maxima.
Chapter 0
See why a list of points breaks the tools that work on images
A car's LiDAR spins ten times a second. Each turn returns about 100,000 dots, each one a place where a laser hit something. You store them as an array with one row per dot. That array is a point cloud: a set of N points, each an (x, y, z) position. Some clouds add numbers, such as the strength of each echo.
An image is a grid, so every pixel has a fixed neighbour to its right. A convolution slides a small filter over that grid. A point cloud has no grid. Point 7 has no "point to the right".
The rows also have no order. The sensor writes them in firing order, but a shuffled array is the same cloud. So a network that reads the array as one long vector sees a new input after every shuffle. It must give the same answer for all N! orders (N factorial: N × (N − 1) × … × 1).
Each point shows its row number. Press Shuffle: the rows move, the dots do not. Raise N and watch the count of orders explode.
Made-up points. The count of orders is exact: N! for N different points.
Work the number. With 6 points there are 6! = 720 orders. With 10 there are 3,628,800. With 1,024 points, the size PointNet used, the count has 2,640 digits. No training set can show a network every order.
The obvious fix is to drop the points into a 3D grid of small cubes and run a 3D convolution. That works, but most cubes are empty, because a scan only touches surfaces. Chapter 2 uses a grid for a different job: to thin the cloud.
The symptom is a model that is right in testing and wrong in use, after a new driver writes the points in another order. To measure it, run the model on the same cloud ten times, shuffled each time, and compare the outputs. The fix is an architecture whose output cannot depend on order (Chapter 5).
Chapter 1
Turn two angles and a range into x, y, z, and see why far surfaces get few points
A spinning LiDAR has a column of lasers, each at a fixed angle above or below the horizon. The column spins and each laser fires many times per turn. Every echo gives a range: how far the light went.
The KITTI driving dataset used a Velodyne HDL-64E: 64 lasers, 10 turns a second, about 100,000 points per turn. So each laser fires about 100,000 / 64 = 1,562 times per turn, one shot every 360 / 1,562 = 0.23°.
Each echo arrives as three numbers. Call the range r, the turn angle around the vertical axis the azimuth θ (theta), and the laser's angle above the horizon the elevation φ (phi). A point below the horizon has a negative φ.
x equals r cos phi cos theta; y equals r cos phi sin theta; z equals r sin phi.
Split the range r into a flat part, r cos phi, and a height, r sin phi. Then split the flat part between x and y by the azimuth theta.
With made-up numbers: r = 20 m, θ = 30°, φ = −10°. The flat part is 20 × 0.985 = 19.70 m.
x = 19.70 × 0.866 = 17.06 m. y = 19.70 × 0.5 = 9.85 m. z = 20 × (−0.174) = −3.47 m: 3.47 m below the sensor.
Each line is one laser seen from the side. Its dot is where it hits the road. Pick the number of lasers, then slide the distance and read the gap between rings there.
Illustrative layout: the sensor sits 1.7 m above a flat road and its lasers are spread evenly from +2° to −24.8°. Real sensors space their lasers unevenly. The 0.23° shot spacing follows from the KITTI figures above.
Work the rings with the device's spacing: 64 lasers over 26.8° sit 0.43° apart. A laser at −8° hits the road at 1.7 / tan 8° = 12.1 m. The next laser, 0.43° lower, hits at 11.5 m: a gap of 0.6 m. Near the horizon, lasers at −2.00° and −2.43° hit at 48.7 m and 40.1 m: a gap of 8.5 m. Along each ring, shots 0.23° apart sit 0.05 m apart at 12 m and 0.20 m apart at 49 m.
So density falls with range: a near car gets many points, the same car far away a few. Every method here must cope with that.
The symptom is a detector that finds near cars and misses far ones. To measure it, plot recall against distance in 10 m bins. The fix starts with the data: train on far examples too, and use neighbourhoods measured in metres, not in point counts (Chapter 3).
Chapter 2
Thin a cloud by cutting space into cubes and keeping one average point in each
The road near the car holds thousands of points in a few square metres. Far walls hold a handful. Most later steps cost time per point, so the dense patch wastes work and also outvotes the rest.
A voxel is a small cube of space, a 3D pixel. A voxel grid filter cuts space into cubes of side s and replaces all the points in each cube with their average, the centroid. Dense patches shrink a lot. Sparse ones barely change.
To find a point's cube, divide each coordinate by s and round down. Call the point (x, y, z) and its cube's integer label (i, j, k).
i, j, k equals the floor of x over s, the floor of y over s, and the floor of z over s.
Divide x, y and z by the voxel size s and round each down. Group the points by the three labels i, j, k. Replace each group by its average point.
With made-up points and s = 0.25 m: (0.12, 0.31, 0.05) and (0.18, 0.27, 0.09) both get label (0, 1, 0). Their centroid is (0.15, 0.29, 0.07). In the table below, 5 points become 3.
| Point | x, y, z (m) | Label i, j, k | Centroid of its cube |
|---|---|---|---|
| 1 | 0.12, 0.31, 0.05 | 0, 1, 0 | 0.15, 0.29, 0.07 |
| 2 | 0.18, 0.27, 0.09 | 0, 1, 0 | 0.15, 0.29, 0.07 |
| 3 | 0.45, 0.05, 0.02 | 1, 0, 0 | 0.43, 0.08, 0.04 |
| 4 | 0.41, 0.11, 0.06 | 1, 0, 0 | 0.43, 0.08, 0.04 |
| 5 | 0.30, 0.30, 0.04 | 1, 1, 0 | 0.30, 0.30, 0.04 |
Blue dots are one sweep seen from above; the sensor is the yellow ring. Slide the voxel size and watch the warm centroids. Find where the pillar by the top wall merges with it. Where the cube edges fall matters too.
Illustrative 2D sweep: one shot every 1° in a 10 m by 6 m room with a 0.15 m pillar near the top wall. The 3D filter works the same way with cubes.
In code, the labels become a key and one group-by does the rest: keys = np.floor(P / s), then average the rows that share a key. It costs one pass over the points, so it runs on every sweep.
The symptom is a pole or a thin person that vanishes from the thinned cloud. The cube is larger than the object, so the object's few points merge with the ground. To measure it, overlay the thinned cloud on the raw one at the smallest object you care about. The fix is a voxel smaller than that object.
Chapter 3
Gather the points near a query, by distance or by count, and find them fast
A single point says nothing about shape. Is it on a flat road, a curb or a pole? You can only tell from the points around it. Normals, PointNet++ and ICP all start by asking: which points are near this one?
There are two ways to ask. The ball query returns every point within a radius r of the query point q. The k nearest neighbours (kNN) query returns the k closest points, near or far. Call the cloud's points pj, numbered by j.
N-r of q equals the set of all j such that the length of p-j minus q is at most r.
For each point p-j, measure its distance to q. Keep j if the distance is at most r. To compare, you can skip the square root and test the squared distance against r squared.
With made-up points around q = (0, 0, 0) and r = 0.3 m: the distances are 0.224, 0.332, 0.250, 0.500 and 0.245 m. Points 1, 3 and 5 pass. Nr(q) has 3 members.
Tap anywhere to move the yellow query. Compare the ball with k nearest, first near the sensor, then at the far wall.
The same illustrative sweep as Chapter 2, without thinning.
Near the sensor, a 0.3 m ball holds about 20 points. At the far wall it holds two. kNN always returns k points, but far away they can span most of a metre and mix two surfaces. PointNet++ chose the ball because its size in metres stays fixed everywhere.
Speed matters. Checking every point for every query costs N × N distance tests: 1010 for 100,000 points. A k-d tree splits space in half again and again, along x, then y, then z. A query then walks about log2 N levels, about 17 for 100,000 points. All queries together cost about N log2 N = 1.7 million steps, roughly 6,000 times fewer.
The symptom is normals and features that look fine nearby and noisy far away. To measure it, histogram the neighbour count per point against range. The fix is a ball radius sized for the far points, a minimum count, or both.
Chapter 4
Find which way a surface faces from the spread of a point's neighbours
Where is the road flat, and where does a curb rise? Each point needs a normal: the direction straight out of the surface. Road normals point up; a curb face's point sideways.
On a flat patch, a point's neighbours spread wide in two directions and hardly at all in the third. That thin direction is the normal. PCA (principal component analysis) finds it from a 3 × 3 table of spreads, the covariance matrix.
Call the k neighbours pj and their average p̄ (p-bar). Call the covariance matrix C.
C equals one over k times the sum over j of, p-j minus p-bar, times p-j minus p-bar transposed.
Subtract p-bar from each neighbour p-j. Multiply each result, as a column, by itself as a row. Add the k tables and divide by k. That average table is C.
With made-up neighbours on a gentle slope: (0, 0, 0), (1, 0, 0.1), (0, 1, 0), (1, 1, 0.1), (0.5, 0.5, 0.05). Then p̄ = (0.5, 0.5, 0.05). C = [[0.2, 0, 0.02], [0, 0.2, 0], [0.02, 0, 0.002]].
The directions of spread are C's eigenvectors v, each with an eigenvalue λ (lambda): the spread along it. Number them from small to large: λ0 ≤ λ1 ≤ λ2. The normal n is the eigenvector of the smallest, and the surface variation σ (sigma) says how far the patch is from flat.
C times v equals lambda times v; n equals v-zero; sigma equals lambda-zero over lambda-zero plus lambda-one plus lambda-two.
Ask numpy for the eigenvectors and eigenvalues of C. The eigenvector with the smallest eigenvalue, lambda-zero, is the normal n. Divide lambda-zero by the sum of all three to get sigma.
For the C above: λ = 0, 0.200, 0.202. So n = (−0.0995, 0, 0.995), the slope's true normal (−0.1, 0, 1) scaled to length 1, and σ = 0. Lift the middle point to z = 0.25: λ0 = 0.0063 and σ = 0.0155. The bump shows.
Tap a point. The purple ellipse shows the neighbours' spread; the arrow is the thin direction. Try the step corner, then raise the noise and the radius.
Illustrative 2D profile, so C is 2 by 2 and σ runs from 0 to one half. We flip normals to face the sensor, which sits above the scene.
PCA gives a direction, not a side: v and −v are both eigenvectors. Flip each normal to face the sensor, which saw that side.
The symptom is normals that lean at every edge, so a curb looks like a ramp. The neighbourhood straddles two surfaces. To measure it, map σ: edges light up. The fix is a smaller radius at edges, or to trust only normals with a small σ.
Chapter 5
Score each point with the same small network, then combine with an operation that cannot see order
We want a network whose answer survives any shuffle of the rows. Some operations already behave that way. 3 + 5 + 2 is 2 + 3 + 5, and the largest of (3, 5, 2) is the largest of (2, 3, 5).
A symmetric function gives the same output for any order of its inputs. Sum, mean and max are symmetric. Gluing the inputs end to end, called concatenation, is not.
The recipe has two steps. First run the same small network on every point alone. Call it h, the shared MLP: it turns one point xi into a feature vector. Then take the largest value of each feature over all points, a max-pool. A last network γ (gamma) reads that summary. Call the whole cloud S and the output f(S).
f of S equals gamma of, the max over i of h of x-i.
Run h on each point x-i to get a row of features. Stack the rows. Take the largest value in each column. Feed that one row to gamma. Shuffling the points shuffles the rows but not the column maxima.
With made-up weights: h(x) = ReLU of (x1, x2, x1 − x2). Points (0.2, 0.9), (0.7, 0.1), (0.5, 0.5) give rows (0.2, 0.9, 0), (0.7, 0.1, 0.6), (0.5, 0.5, 0). The column maxima are (0.7, 0.9, 0.6), in every order.
Each row holds one point's three features. Pick how to combine the rows, then press Shuffle. Red marks every output slot that changed.
The three points and weights are the made-up numbers above.
Why max and not sum? A sum grows with the number of points, so a dense scan of a chair looks unlike a sparse one. A max acts as a detector: each feature reports the one point that shows it most. The PointNet authors compared max, average and an attention-weighted sum, and max won by a wide margin.
The PointNet paper also proves that this form is enough. Take any continuous function of a set: one that changes little when the points move a little. Some γ of a max of h comes as close to it as you like, given enough features.
The symptom is a model whose output shifts when you resample the same object with more points. A mean or a sum crept in where a max belonged, or batch statistics mix points across clouds. To measure it, score one object at 512, 1,024 and 2,048 points. The fix is a max, or a mean if density truly carries meaning.
Chapter 6
Follow the tensor shapes through PointNet and find the few points that decide its answer
PointNet (Qi, Su, Mo and Guibas, 2017) is the recipe of Chapter 5 at full size. The table follows one cloud of N points through the classification network. N can change from cloud to cloud; no weight depends on it.
| Step | What it does | Output shape |
|---|---|---|
| Input | N points, x, y, z each | N × 3 |
| Input T-Net | a small network predicts a 3 × 3 matrix that turns the cloud to a standard pose | N × 3 |
| Shared MLP (64, 64) | the same two layers on every point | N × 64 |
| Feature T-Net | a 64 × 64 matrix aligns the features | N × 64 |
| Shared MLP (64, 128, 1024) | three more layers per point | N × 1024 |
| Max-pool | the largest of each column | 1024 |
| MLP (512, 256, k) | γ: class scores | k |
For segmentation, a label for every point, PointNet glues the 1,024 global numbers onto each point's 64 local features. Each point then sees itself and the whole shape: N × 1088. More shared layers end in one label per point.
Count the weights of the shared layers. A layer from din to dout numbers has (din + 1) × dout weights, counting one bias per output. The five layers, 3→64→64→64→128→1024, hold 256 + 4,160 + 4,160 + 8,320 + 132,096 = 148,992 weights. That is the same for 100 points or 100,000. A flattening MLP's first layer, from 1,024 points to 64 units, needs (3,072 + 1) × 64 = 196,672 weights. It accepts only 1,024 points in one order.
Each of the 1,024 columns keeps one winner. So at most 1,024 points decide the global feature, whatever N is. The paper calls them the critical point set: delete any other point and the output does not move. The number of features, the bottleneck dimension, caps its size.
Each feature probes one direction; its winner is a warm dot. Slide the feature count. Then delete everything else, or drop a random half, and read how far the global feature moves.
Illustrative: our features are straight-line probes, so the winners sit on the outer edge. PointNet's learned features also pick inner points; its Figure 7 shows critical sets that trace a skeleton of each shape.
This explains PointNet's robustness. On ModelNet40 (12,311 CAD models in 40 classes, 1,024 points each) it reached 89.2% accuracy. With half the points missing, accuracy fell by only 2.4 points with farthest-point sampling and 3.8 points with random sampling. The input T-Net added 0.8 points over no alignment.
The symptom is a model that is confident on whole objects and fooled by a few stray points far from the object. A stray point can win a column. To measure it, add 10 random outlier points and watch the scores. The fix is to clean outliers first, by removing points with too few neighbours.
Chapter 7
Pick spread-out centres, run a small PointNet on each neighbourhood, and repeat
A CNN sees an edge, then a corner, then a wheel, then a car. Each layer looks at a small patch of the layer below. PointNet jumps from single points to the whole cloud in one max. It never sees a corner as a corner.
PointNet++ (Qi, Yi, Su and Guibas, 2017) adds patches. One set abstraction level does three things:
The next level repeats on the centres with a larger ball. The classification network uses 512 centres with radius 0.2, then 128 centres with radius 0.4, on clouds scaled into a unit ball.
Random centres bunch up in dense regions. Farthest point sampling (FPS) picks each new centre as far as possible from those already chosen. Call the chosen centres c1 to cm.
c m-plus-one equals the argmax over j of, the min over i up to m of the length of p-j minus c-i.
For each point p-j, find its distance to the nearest centre c-i chosen so far. Pick the point where that distance is largest. Add it as the next centre and repeat.
With made-up points (0, 0), (1, 0), (4, 0), (5, 0), (2, 3), start at c1 = (0, 0). The distances are 0, 1, 4, 5, 3.61, so c2 = (5, 0). Nearest-centre distances become 0, 1, 1, 0, 3.61, so c3 = (2, 3).
Warm dots are centres, yellow rings their balls. Compare farthest point with random, and count the blue points no ball reaches.
Illustrative cloud of 400 points in a unit square: 250 in a dense cluster, 150 spread thin. Random centres use a fixed seed.
PointNet++ raised ModelNet40 accuracy from PointNet's 89.2% to 90.7%, and to 91.9% when it also read surface normals and used 5,000 points.
Inside each patch, PointNet++ still pools with a max. A point transformer (Zhao, Jiang, Jia, Torr and Koltun, 2021) replaces the max with attention. Each point weighs its neighbours by their features and by their offset in space. On the S3DIS indoor scene benchmark it reached 70.4% mean intersection over union on Area 5.
| Model | Neighbourhood | How it combines a patch |
|---|---|---|
| PointNet | the whole cloud | one max over all points |
| PointNet++ | a ball around each FPS centre | a small PointNet, max inside the ball |
| Point transformer | each point's nearest neighbours | a weighted sum, weights from features and relative position |
The symptom is a model that does well on evenly sampled CAD shapes and poorly on real scans, which are dense near the sensor. To measure it, test on clouds thinned unevenly by range. The fix in PointNet++ is to group at several radii and let the network weigh them.
Chapter 8
Align a new scan to a known one, and let points slide along walls
A robot drives a metre and scans again. The new scan shows the same walls, turned and shifted. Registration finds the rotation R and shift t that lay the new scan, the source, onto the old one, the target.
Iterative closest point (ICP; Besl and McKay, 1992) repeats two steps. Pair each source point with its nearest target point. Then find the R and t that best close the pairs, apply them, and repeat. AA 274A Lesson 7 works the classic version by hand with the SVD.
The classic point-to-point error has a flaw. Two scans hit a wall at different spots, so even at the true pose each pair has a sideways gap. ICP tries to close it and creeps. Point-to-plane ICP (Chen and Medioni, 1991) measures only the gap along the target's normal ni (Chapter 4). Call source point i pi, its partner qi, and the total error E.
E of R and t equals the sum over i of, R p-i plus t minus q-i, dot n-i, all squared.
Move source point p-i by R and t. Take its gap to q-i, keep only the part along n-i, and square it. Add over all pairs. Choose R and t to make E smallest.
With made-up numbers: a moved point at (1.3, 2.1), its partner at (1.0, 2.0) on a floor with n = (0, 1). The gap is (0.3, 0.1). Point-to-point counts 0.09 + 0.01 = 0.10. Point-to-plane counts 0.1 squared = 0.01: the slide along the floor is free.
For a small turn, E becomes a least-squares problem in three numbers: the angle and the two parts of t. One np.linalg.lstsq call solves it.
Pick a method and press Run. The plot shows the angle error per iteration for both methods. Then raise the starting turn until one of them locks on wrong.
Illustrative 2D scans of a 4 m by 2.4 m L-shaped room. The target has a point every 0.1 m; the source is 100 points at random spots, so no pair matches exactly. Normals come from PCA on 6 neighbours. The start shift grows with the turn.
We ran this toy on ten random scans. From a 20° start, point-to-plane came within 0.1° in 3 or 4 iterations; point-to-point needed 9 to 16 to reach 1°. From 60° on, point-to-point locked on wrong every time, point-to-plane once.
The symptom is a confident wrong pose. ICP finds the best pose near its start; in a corridor, sliding is free, so the position along it is unknown. Compare the result with odometry. The fix is a good starting guess and walls in more than one direction.
Chapter 9
Keep the terms, the numbers, the code and the next steps in one place
A point cloud is an unordered set of positions on surfaces, dense near the sensor and sparse far away. Thin it with a voxel grid, find neighbours with a ball or kNN, and read surface direction from PCA. Learn on it with a shared per-point network and a symmetric pool, then add locality. Align two clouds with ICP, and use the normals to let points slide.
| Term | Meaning | Number to remember |
|---|---|---|
| Scan to point | x = r cos φ cos θ, y = r cos φ sin θ, z = r sin φ | 20 m, 30°, −10°: (17.06, 9.85, −3.47) |
| KITTI LiDAR | Velodyne HDL-64E | 64 lasers, 10 Hz, about 100,000 points per turn |
| Voxel label | ⌊x / s⌋ per axis, then average | 5 points, s = 0.25 m: 3 centroids |
| Ball query | all points within r of q | k-d tree: about 17 levels for 100,000 points |
| Normal | eigenvector of the smallest eigenvalue of C | slope (−0.1, 0, 1): n = (−0.0995, 0, 0.995) |
| Symmetric pool | f(S) = γ(maxi h(xi)) | rows→column maxima (0.7, 0.9, 0.6) in any order |
| PointNet | shared MLP, max-pool, MLP | 148,992 shared weights; ModelNet40 89.2% |
| Critical points | the winners of the max-pool | at most K, the pool width (1,024) |
| PointNet++ | FPS centres, ball groups, mini PointNets | 90.7%; 91.9% with normals |
| Point transformer | local attention with relative position | S3DIS Area 5: 70.4% mIoU |
| Point-to-plane ICP | minimise Σ ((R p + t − q) · n)2 | gap (0.3, 0.1) on a floor: 0.01, not 0.10 |
| Form | What it stores | Good for | Cost |
|---|---|---|---|
| Point cloud | surface samples | raw sensor data, detection, registration | needs set networks; no surface |
| Voxel grid | occupied cubes | 3D convolution, mapping | memory grows with volume; most cubes empty |
| Mesh | vertices and triangles | graphics, simulation | hard to get from noisy scans |
| Gaussians or a neural field | a learned scene | photoreal new views | training per scene |
python import numpy as np def voxel_down(P, s): # P: N x 3, s: voxel size in m keys = np.floor(P / s).astype(np.int64) # N x 3 cube labels _, inv = np.unique(keys, axis=0, return_inverse=True) inv = inv.ravel() sums = np.zeros((inv.max() + 1, 3)); np.add.at(sums, inv, P) return sums / np.bincount(inv)[:, None] # M x 3 centroids def normal(nbrs): # nbrs: k x 3 d = nbrs - nbrs.mean(0) C = d.T @ d / len(nbrs) # 3 x 3 covariance lam, V = np.linalg.eigh(C) # eigenvalues small to large return V[:, 0], lam[0] / lam.sum() # normal, surface variation def pointnet_feature(P, layers): # layers: list of (W, b) h = P # N x 3 for W, b in layers: # the same weights on every row h = np.maximum(0, h @ W + b) # N x d_out return h.max(0) # K numbers: any row order gives the same def fps(P, m): # farthest point sampling, m centres idx = [0]; d = np.linalg.norm(P - P[0], axis=1) for _ in range(m - 1): j = int(d.argmax()); idx.append(j) d = np.minimum(d, np.linalg.norm(P - P[j], axis=1)) return P[idx]
Sources: Qi et al., PointNet (CVPR 2017); Qi et al., PointNet++ (NeurIPS 2017); Zhao et al., Point Transformer (ICCV 2021); the KITTI sensor setup.
Now press Present or Teach. Explain from memory: the scan, the voxel label, the ball query, the normal, why a max ignores order, critical points, FPS and point-to-plane ICP. Then go back to the shapes, shuffle the rows, and say why only one model stays put.