plane
Utilities to compute planes from points and manipulate points between 3D and 2D.
Classes:
| Name | Description |
|---|---|
Plane3D |
|
Functions:
| Name | Description |
|---|---|
normal_from_points |
Compute the normal of the plane defined by a set of points with PCA. |
Plane3D
Methods:
| Name | Description |
|---|---|
__init__ |
Plane defined by the equation ax + by + cz + d = 0. |
from_points |
Create a plane from an array of points. |
project_points |
Project the given 3D points onto the plane, giving 2D coordinates. |
unproject_points |
Transforms the given 2D points in the plane's coordinate system back into their 3D coordinates in the main coordinate system. |
Source code in python/src/data_pipeline/utils/plane.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__(a, b, c, d, valid=True)
Plane defined by the equation ax + by + cz + d = 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
numpy.float64
|
|
required |
b
|
numpy.float64
|
|
required |
c
|
numpy.float64
|
|
required |
d
|
numpy.float64
|
|
required |
valid
|
bool
|
Whether the plane is valid and usable. By default True. |
True
|
Source code in python/src/data_pipeline/utils/plane.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
from_points(points)
classmethod
Create a plane from an array of points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
numpy.typing.NDArray[numpy.float64]
|
An array of 3D points of shape (N, 3). |
required |
Returns:
| Type | Description |
|---|---|
utils.plane.Plane3D
|
Plane that best fits through the points. |
Source code in python/src/data_pipeline/utils/plane.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
project_points(points_3D)
Project the given 3D points onto the plane, giving 2D coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_3D
|
numpy.typing.NDArray[numpy.float64]
|
An array of 3D points of shape (N, 3). |
required |
Returns:
| Type | Description |
|---|---|
numpy.typing.NDArray[numpy.float64]
|
An array of shape (N, 2) with the projected 2D points. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the plane is invalid. |
Source code in python/src/data_pipeline/utils/plane.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
unproject_points(points_2D)
Transforms the given 2D points in the plane's coordinate system back into their 3D coordinates in the main coordinate system. The output points of this function are all on the plane.
Warning
This is the inverse of project_points ONLY IF the points are actually on the plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_2D
|
numpy.typing.NDArray[numpy.float64]
|
An array of shape (N, 2) containing 2D points in the plane's coordinate system. |
required |
Returns:
| Type | Description |
|---|---|
numpy.typing.NDArray[numpy.float64]
|
An array of shape (N, 3) containing the 3D coordinates of the given points in the main 3D coordinate system. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the plane is invalid. |
Source code in python/src/data_pipeline/utils/plane.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
normal_from_points(points)
Compute the normal of the plane defined by a set of points with PCA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
numpy.typing.NDArray[numpy.float64]
|
Set of 3D points (N, 3). |
required |
Returns:
| Type | Description |
|---|---|
numpy.typing.NDArray[numpy.float64]
|
Normal vector (3,). |
bool
|
Whether the normal is valid (False if the points were collinear for example). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the input points are not 3D. |
Source code in python/src/data_pipeline/utils/plane.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |