public Polygon2D Geometry2D() { var normalizedThicknessDirection = ThicknessDirection.ToNormalizedVector(); if (normalizedThicknessDirection.IsParallelTo(Vector3D.ZAxis)) { var halfLengthVector = ConnectorPlateType.Length / 2 * LengthDirection.ToDirection2D().ToNormalizedVector(); var halfWidthVector = ConnectorPlateType.Width / 2 * WidthDirection.ToDirection2D().ToNormalizedVector(); var center2D = Center.ToPoint2D(); return(new Polygon2D { Vertices = new List <Point2D> { center2D - halfLengthVector - halfWidthVector, center2D - halfLengthVector + halfWidthVector, center2D + halfLengthVector + halfWidthVector, center2D + halfLengthVector - halfWidthVector, }, }); } throw new Exception("Connector plate cannot be displayed as a 2D polygon."); }
public Polyhedron Geometry3D() { var halfLengthVector = ConnectorPlateType.Length / 2 * LengthDirection.ToNormalizedVector(); var halfWidthVector = ConnectorPlateType.Width / 2 * WidthDirection.ToNormalizedVector(); var thicknessVector = ConnectorPlateType.Thickness * ThicknessDirection.ToNormalizedVector(); return(new Polyhedron { Faces = new List <Polygon3D> { new Polygon3D { Vertices = new List <Point3D> { Center - halfLengthVector - halfWidthVector, Center - halfLengthVector + halfWidthVector, Center + halfLengthVector + halfWidthVector, Center + halfLengthVector - halfWidthVector, }, }, new Polygon3D { Vertices = new List <Point3D> { Center - halfLengthVector - halfWidthVector, Center - halfLengthVector + halfWidthVector, Center - halfLengthVector + halfWidthVector + thicknessVector, Center - halfLengthVector - halfWidthVector + thicknessVector, } }, new Polygon3D { Vertices = new List <Point3D> { Center - halfLengthVector + halfWidthVector, Center + halfLengthVector + halfWidthVector, Center + halfLengthVector + halfWidthVector + thicknessVector, Center - halfLengthVector + halfWidthVector + thicknessVector, } }, new Polygon3D { Vertices = new List <Point3D> { Center + halfLengthVector + halfWidthVector, Center + halfLengthVector - halfWidthVector, Center + halfLengthVector - halfWidthVector + thicknessVector, Center + halfLengthVector + halfWidthVector + thicknessVector, } }, new Polygon3D { Vertices = new List <Point3D> { Center + halfLengthVector - halfWidthVector, Center - halfLengthVector - halfWidthVector, Center - halfLengthVector - halfWidthVector + thicknessVector, Center + halfLengthVector - halfWidthVector + thicknessVector, } }, new Polygon3D { Vertices = new List <Point3D> { Center + halfLengthVector - halfWidthVector + thicknessVector, Center + halfLengthVector + halfWidthVector + thicknessVector, Center - halfLengthVector + halfWidthVector + thicknessVector, Center - halfLengthVector - halfWidthVector + thicknessVector, } }, }, }); }