Guest User

Untitled

a guest
Nov 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. private static bool IsTangentConnected( Solid3D.Face face0, Solid3D.Face face1, Solid3D.Edge edge)
  2. {
  3. var angle = 1.5 / 180 * Math.PI;
  4.  
  5. // Then the two faces share an edge.
  6. var surfaces0 = face0.Parametric;
  7. var surfaces1 = face1.Parametric;
  8.  
  9. Vector3D Normal(Surface[] surfaces, Point3D p)
  10. {
  11. return surfaces
  12. .Select
  13. (s =>
  14. {
  15. // The below call to Project is very slow
  16. if (!s.Project(p, out var coord2D))
  17. throw new Exception("Unexpected");
  18. ;
  19. return (p: s.PointAt(coord2D), n: s.Normal(coord2D));
  20. })
  21. .MaxBy(q => p.DistanceTo(q.p))
  22. [0].n;
  23. }
  24.  
  25. var pl = edge.Curve.PointAt(edge.Curve.Domain.Low);
  26. var pm = edge.Curve.PointAt(edge.Curve.Domain.Mid);
  27. var ph = edge.Curve.PointAt(edge.Curve.Domain.High);
  28.  
  29. var vl0 = Normal(surfaces0, pl);
  30. var vl1 = Normal(surfaces1, pl);
  31.  
  32. var vm0 = Normal(surfaces0, pm);
  33. var vm1 = Normal(surfaces1, pm);
  34.  
  35. var vh0 = Normal(surfaces0, ph);
  36. var vh1 = Normal(surfaces1, ph);
  37.  
  38. var r = Vector3D.AngleBetween(vl0, vl1) < angle
  39. && Vector3D.AngleBetween(vm0, vm1) < angle
  40. && Vector3D.AngleBetween(vh0, vh1) < angle;
  41.  
  42. return r;
  43.  
  44. }
Add Comment
Please, Sign In to add comment