// Add a normal for a polygon.
// Assumes the points are coplanar.
// Assumes the points are outwardly oriented.
public static void AddPolygonNormal(this MeshGeometry3D mesh,
double length, double thickness, params Point3D[] points)
{
// Find the "center" point.
double x = 0, y = 0, z = 0;
foreach (Point3D point in points)
{
x += point.X;
y += point.Y;
z += point.Z;
}
Point3D endpoint1 = new Point3D(
x / points.Length,
y / points.Length,
z / points.Length);
// Get the polygon's normal.
Vector3D n = FindTriangleNormal(
points[0], points[1], points[2]);
// Set the length.
n = n.Scale(length);
// Find the segment's other end point.
Point3D endpoint2 = endpoint1 + n;
// Create the segment.
AddSegment(mesh, endpoint1, endpoint2, thickness);
}