... | ... |
@@ -180,30 +180,28 @@ def simplex_volume_in_embedding(vertices) -> float: |
180 | 180 |
That is: dim > len(vertices) - 1. For example if you would like to know the |
181 | 181 |
surface area of a triangle in a 3d space. |
182 | 182 |
|
183 |
+ This algorithm has not been tested for numerical stability. |
|
184 |
+ |
|
183 | 185 |
Parameters |
184 | 186 |
---------- |
185 |
- vertices: arraylike (2 dimensional) |
|
186 |
- array of points |
|
187 |
+ vertices : 2D arraylike of floats |
|
187 | 188 |
|
188 | 189 |
Returns |
189 | 190 |
------- |
190 |
- volume: int |
|
191 |
+ volume : int |
|
191 | 192 |
the volume of the simplex with given vertices. |
192 | 193 |
|
193 | 194 |
Raises |
194 | 195 |
------ |
195 |
- ValueError: |
|
196 |
+ ValueError |
|
196 | 197 |
if the vertices do not form a simplex (for example, |
197 | 198 |
because they are coplanar, colinear or coincident). |
198 |
- |
|
199 |
- Warning: this algorithm has not been tested for numerical stability. |
|
200 | 199 |
""" |
201 | 200 |
|
202 | 201 |
# Implements http://mathworld.wolfram.com/Cayley-MengerDeterminant.html |
203 | 202 |
# Modified from https://codereview.stackexchange.com/questions/77593/calculating-the-volume-of-a-tetrahedron |
204 | 203 |
|
205 |
- |
|
206 |
- vertices = np.array(vertices, dtype=float) |
|
204 |
+ vertices = np.asarray(vertices, dtype=float) |
|
207 | 205 |
dim = len(vertices[0]) |
208 | 206 |
if dim == 2: |
209 | 207 |
# Heron's formula |