Last active
November 21, 2017 06:48
-
-
Save bradphelan/367d8d74b0c8549f3da0e343aca4d768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3D Normal(Solid3D.Face face, Point3D p) | |
{ | |
return face | |
.Parametric | |
.SelectMany | |
(s => s.PointInversion( p, 1e-3, out var coord2D ) | |
? Some((p: s.PointAt(coord2D), n: s.Normal(coord2D))) | |
: None ) | |
.MaxBy(q => p.DistanceTo(q.p)) | |
[0].n; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trick is that Optional implements IEnumerable so works with SelectMany to flatten it.