mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Check whether points in Plane.from_points lie along a line.
This commit is contained in:
parent
c907c85675
commit
a5d724aa2e
1 changed files with 12 additions and 3 deletions
|
|
@ -737,16 +737,25 @@ class Plane(PlaneMixin, Surface):
|
|||
Plane
|
||||
Plane that passes through the three points
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If all three points lie along a line
|
||||
|
||||
"""
|
||||
# Convert to numpy arrays
|
||||
p1 = np.asarray(p1)
|
||||
p2 = np.asarray(p2)
|
||||
p3 = np.asarray(p3)
|
||||
p1 = np.asarray(p1, dtype=float)
|
||||
p2 = np.asarray(p2, dtype=float)
|
||||
p3 = np.asarray(p3, dtype=float)
|
||||
|
||||
# Find normal vector to plane by taking cross product of two vectors
|
||||
# connecting p1->p2 and p1->p3
|
||||
n = np.cross(p2 - p1, p3 - p1)
|
||||
|
||||
# Check for points along a line
|
||||
if np.allclose(n, 0.):
|
||||
raise ValueError("All three points appear to lie along a line.")
|
||||
|
||||
# The equation of the plane will by n·(<x,y,z> - p1) = 0. Determine
|
||||
# coefficients a, b, c, and d based on that
|
||||
a, b, c = n
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue