Lagrange
compute_pointcloud_pca.h
1/*
2 * Copyright 2019 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#ifdef LAGRANGE_ENABLE_LEGACY_FUNCTIONS
15 #include <lagrange/legacy/compute_pointcloud_pca.h>
16#endif
17
18#include <lagrange/utils/span.h>
19
20namespace lagrange {
21
23{
28 bool shift_centroid = false;
29
33 bool normalize = false;
34};
35
36template <typename Scalar>
38{
40 std::array<Scalar, 3> center;
41
43 std::array<std::array<Scalar, 3>, 3> eigenvectors;
44
46 std::array<Scalar, 3> eigenvalues;
47};
48
73template <typename Scalar>
75 span<const Scalar> points,
76 ComputePointcloudPCAOptions options = {});
77
78} // namespace lagrange
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition: span.h:27
Main namespace for Lagrange.
Definition: AABBIGL.h:30
PointcloudPCAOutput< Scalar > compute_pointcloud_pca(span< const Scalar > points, ComputePointcloudPCAOptions options={})
Finds the principal components for a pointcloud.
Definition: compute_pointcloud_pca.cpp:23
Definition: compute_pointcloud_pca.h:23
bool shift_centroid
when true : covariance = (P - centroid) ^ T(P - centroid) when false : covariance = (P) ^ T(P)
Definition: compute_pointcloud_pca.h:28
bool normalize
should we divide the result by number of points?
Definition: compute_pointcloud_pca.h:33
Definition: compute_pointcloud_pca.h:38
std::array< Scalar, 3 > center
The point around which the covariance matrix is evaluated.
Definition: compute_pointcloud_pca.h:40
std::array< std::array< Scalar, 3 >, 3 > eigenvectors
The 3 components, sorted by weight magnitudes.
Definition: compute_pointcloud_pca.h:43
std::array< Scalar, 3 > eigenvalues
Each entry is a weight for the corresponding principal component.
Definition: compute_pointcloud_pca.h:46