/// <summary> /// Extends a polygon to a 3 dimensional solid. /// Makes a copy of the polygon shifted over by the extrusion vector, then connects corresponding vertices. /// </summary> public Polyhedron Extrude(FreeVector extrusionVector) { if (this.IsParallelTo(extrusionVector)) { throw new Exception("Extrusion vector cannot be parallel to extruding face"); } if (extrusionVector.ScalarProjection(NormalDirection).AbsoluteValue() < Inches.Tolerance * Inches) { throw new Exception("Extrusion vector is too small in the normal direction."); } ; var baseFace = extrusionVector.ScalarProjection(NormalDirection) < ZeroDistance ? this : this.ReverseOrientation(); var faces = new List <Polygon> { baseFace }; var oppositeFace = new List <LineSegment>(); foreach (var segment in baseFace.Edges) { var opposite = segment.Translate(extrusionVector); var sideFace = new Polygon ( ValidateOption.Dont, opposite.BasePoint, opposite.EndPoint, segment.EndPoint, segment.BasePoint ); faces.Add(sideFace); oppositeFace.Add(opposite.Reverse()); } oppositeFace.Reverse(); faces.Add(new Polygon(oppositeFace, ValidateOption.Dont)); var solid = new Polyhedron(faces, ValidateOption.Dont); return(solid); }
/// <summary> /// Returns whether ot not this line itnersects the Polyhedron /// </summary> public bool Intersects(Polyhedron polyhedron) => polyhedron.Faces.Any(Intersects);