public double GetArea() { // the normal can be taken from the product of two segments on the polyline if (Count() < 3) { return(double.NaN); } var normal = Normal() * -1; var firstSegment = FirstSegment(); var up = XbimVector3D.CrossProduct(normal, firstSegment); var campos = new XbimVector3D( _geomPoints[0].Point.X, _geomPoints[0].Point.Y, _geomPoints[0].Point.Z ); var target = campos + normal; var m = XbimMatrix3D.CreateLookAt(campos, target, up); var point = new XbimPoint3D[Count()]; for (var i = 0; i < point.Length; i++) { var pBefore = new XbimPoint3D( _geomPoints[i].Point.X, _geomPoints[i].Point.Y, _geomPoints[i].Point.Z ); var pAft = m.Transform(pBefore); point[i] = pAft; } // http://stackoverflow.com/questions/2553149/area-of-a-irregular-shape // it assumes that the last point is NOT the same of the first one, but it tolerates the case. double area = 0.0f; var numVertices = Count(); for (var i = 0; i < numVertices - 1; ++i) { area += point[i].X * point[i + 1].Y - point[i + 1].X * point[i].Y; } area += point[numVertices - 1].X * point[0].Y - point[0].X * point[numVertices - 1].Y; area /= 2.0; return(area); }