public static ConstructVector3D ( double xComponent, double yComponent, double zComponent ) : IVector3D | ||
xComponent | double | |
yComponent | double | |
zComponent | double | |
return | IVector3D |
public static IGeometry GetExample3() { const double DegreesOfRotation = 45; //Transform3D: Cylinder Rotated Around An Axis Via RotateVector3D() IGeometry geometry = Vector3DExamples.GetExample3(); //Construct A Vector3D Corresponding To The Desired Axis Of Rotation IVector3D axisOfRotationVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0); //Obtain Angle Of Rotation In Radians double angleOfRotationInRadians = GeometryUtilities.GetRadians(DegreesOfRotation); ITransform3D transform3D = geometry as ITransform3D; transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians); return(geometry); }
public static IGeometry GetExample4() { const double XScale = 0.5; const double YScale = 0.5; const double ZScale = 2; const double XOffset = -5; const double YOffset = -5; const double ZOffset = -8; const double DegreesOfRotation = 90; //Transform3D: Cylinder Scaled, Rotated, Repositioned Via Move3D(), Scale3D(), RotateVector3D() IGeometry geometry = Vector3DExamples.GetExample3(); ITransform3D transform3D = geometry as ITransform3D; //Stretch The Cylinder So It Looks Like A Tube IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); transform3D.Scale3D(originPoint, XScale, YScale, ZScale); //Rotate The Cylinder So It Lies On Its Side IVector3D axisOfRotationVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0); double angleOfRotationInRadians = GeometryUtilities.GetRadians(DegreesOfRotation); transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians); //Reposition The Cylinder So It Is Located Underground transform3D.Move3D(XOffset, YOffset, ZOffset); return(geometry); }
public static IGeometry GetExample5() { const double CylinderBaseDegrees = 360.0; const int CylinderBaseDivisions = 8; const double VectorComponentOffset = 0.0000001; const double CylinderBaseRadius = 3; const double CylinderUpperZ = 8; const double CylinderLowerZ = 0; //Vector3D: Cylinder, TriangleStrip With 8 Vertices IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IPointCollection triangleStripPointCollection = new TriangleStripClass(); //Set Cylinder Base Origin To (0, 0, 0) IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); //Define Upper Portion Of Axis Around Which Vector Should Be Rotated To Generate Cylinder Base Vertices IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); //Define Lower Portion of Axis Around Which Vector Should Be Rotated To Generate Cylinder Base Vertices IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); //Add A Slight Offset To X or Y Component Of One Of Axis Vectors So Cross Product Does Not Return A Zero-Length Vector lowerAxisVector3D.XComponent += VectorComponentOffset; //Obtain Cross Product Of Upper And Lower Axis Vectors To Obtain Normal Vector To Axis Of Rotation To Generate Cylinder Base Vertices IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; //Set Normal Vector Magnitude Equal To Radius Of Cylinder Base normalVector3D.Magnitude = CylinderBaseRadius; //Obtain Angle Of Rotation In Radians As Function Of Number Of Divisions Within 360 Degree Sweep Of Cylinder Base double rotationAngleInRadians = GeometryUtilities.GetRadians(CylinderBaseDegrees / CylinderBaseDivisions); for (int i = 0; i < CylinderBaseDivisions; i++) { //Rotate Normal Vector Specified Rotation Angle In Radians Around Either Upper Or Lower Axis normalVector3D.Rotate(rotationAngleInRadians, upperAxisVector3D); //Construct Cylinder Base Vertex Whose XY Coordinates Are The Sum Of Origin XY Coordinates And Normal Vector XY Components IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent, 0); //Construct Lower Base Vertex From This Point And Add To TriangleStrip IPoint lowerVertexPoint = GeometryUtilities.ConstructPoint3D(vertexPoint.X, vertexPoint.Y, CylinderLowerZ); triangleStripPointCollection.AddPoint(lowerVertexPoint, ref _missing, ref _missing); //Construct Upper Base Vertex From This Point And Add To TriangleStrip IPoint upperVertexPoint = GeometryUtilities.ConstructPoint3D(vertexPoint.X, vertexPoint.Y, CylinderUpperZ); triangleStripPointCollection.AddPoint(upperVertexPoint, ref _missing, ref _missing); } //Re-Add The First And Second Points Of The Triangle Strip (First Two Vertices Added) To Close The Strip triangleStripPointCollection.AddPoint(triangleStripPointCollection.get_Point(0), ref _missing, ref _missing); triangleStripPointCollection.AddPoint(triangleStripPointCollection.get_Point(1), ref _missing, ref _missing); //Add TriangleStrip To MultiPatch multiPatchGeometryCollection.AddGeometry(triangleStripPointCollection as IGeometry, ref _missing, ref _missing); return(multiPatchGeometryCollection as IGeometry); }
public static IGeometry GetExample1() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 5.0; const double CircleZ = 0.0; //Vector3D: Circle, TriangleFan With 36 Vertices IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IPointCollection triangleFanPointCollection = new TriangleFanClass(); //Set Circle Origin To (0, 0, CircleZ) IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, CircleZ); //Add Origin Point To Triangle Fan triangleFanPointCollection.AddPoint(originPoint, ref _missing, ref _missing); //Define Upper Portion Of Axis Around Which Vector Should Be Rotated To Generate Circle Vertices IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); //Define Lower Portion of Axis Around Which Vector Should Be Rotated To Generate Circle Vertices IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); //Add Slight Offset To X or Y Component Of One Of Axis Vectors So Cross Product Does Not Return A Zero-Length Vector lowerAxisVector3D.XComponent += VectorComponentOffset; //Obtain Cross Product Of Upper And Lower Axis Vectors To Obtain Normal Vector To Axis Of Rotation To Generate Circle Vertices IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; //Set Normal Vector Magnitude Equal To Radius Of Circle normalVector3D.Magnitude = CircleRadius; //Obtain Angle Of Rotation In Radians As Function Of Number Of Divisions Within 360 Degree Sweep Of Circle double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); for (int i = 0; i < CircleDivisions; i++) { //Rotate Normal Vector Specified Rotation Angle In Radians Around Either Upper Or Lower Axis normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); //Construct Circle Vertex Whose XY Coordinates Are The Sum Of Origin XY Coordinates And Normal Vector XY Components IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent, CircleZ); //Add Vertex To TriangleFan triangleFanPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } //Re-Add The Second Point Of The Triangle Fan (First Vertex Added) To Close The Fan triangleFanPointCollection.AddPoint(triangleFanPointCollection.get_Point(1), ref _missing, ref _missing); //Add TriangleFan To MultiPatch multiPatchGeometryCollection.AddGeometry(triangleFanPointCollection as IGeometry, ref _missing, ref _missing); return(multiPatchGeometryCollection as IGeometry); }
public static IGeometry GetExample4() { const double CircleDegrees = 360.0; const int CircleDivisions = 18; const double VectorComponentOffset = 0.0000001; const double InnerBuildingRadius = 3.0; const double OuterBuildingExteriorRingRadius = 9.0; const double OuterBuildingInteriorRingRadius = 6.0; const double BaseZ = 0.0; const double InnerBuildingZ = 16.0; const double OuterBuildingZ = 6.0; //Composite: Tall Building Protruding Through Outer Ring-Shaped Building IMultiPatch multiPatch = new MultiPatchClass(); IGeometryCollection multiPatchGeometryCollection = multiPatch as IGeometryCollection; IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); //Inner Building IGeometry innerBuildingBaseGeometry = new PolygonClass(); IPointCollection innerBuildingBasePointCollection = innerBuildingBaseGeometry as IPointCollection; //Outer Building IGeometry outerBuildingBaseGeometry = new PolygonClass(); IGeometryCollection outerBuildingBaseGeometryCollection = outerBuildingBaseGeometry as IGeometryCollection; IPointCollection outerBuildingBaseExteriorRingPointCollection = new RingClass(); IPointCollection outerBuildingBaseInteriorRingPointCollection = new RingClass(); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); //Inner Building normalVector3D.Magnitude = InnerBuildingRadius; IPoint innerBuildingBaseVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent); innerBuildingBasePointCollection.AddPoint(innerBuildingBaseVertexPoint, ref _missing, ref _missing); //Outer Building //Exterior Ring normalVector3D.Magnitude = OuterBuildingExteriorRingRadius; IPoint outerBuildingBaseExteriorRingVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent); outerBuildingBaseExteriorRingPointCollection.AddPoint(outerBuildingBaseExteriorRingVertexPoint, ref _missing, ref _missing); //Interior Ring normalVector3D.Magnitude = OuterBuildingInteriorRingRadius; IPoint outerBuildingBaseInteriorRingVertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent); outerBuildingBaseInteriorRingPointCollection.AddPoint(outerBuildingBaseInteriorRingVertexPoint, ref _missing, ref _missing); } IPolygon innerBuildingBasePolygon = innerBuildingBaseGeometry as IPolygon; innerBuildingBasePolygon.Close(); IRing outerBuildingBaseExteriorRing = outerBuildingBaseExteriorRingPointCollection as IRing; outerBuildingBaseExteriorRing.Close(); IRing outerBuildingBaseInteriorRing = outerBuildingBaseInteriorRingPointCollection as IRing; outerBuildingBaseInteriorRing.Close(); outerBuildingBaseInteriorRing.ReverseOrientation(); outerBuildingBaseGeometryCollection.AddGeometry(outerBuildingBaseExteriorRing as IGeometry, ref _missing, ref _missing); outerBuildingBaseGeometryCollection.AddGeometry(outerBuildingBaseInteriorRing as IGeometry, ref _missing, ref _missing); ITopologicalOperator topologicalOperator = outerBuildingBaseGeometry as ITopologicalOperator; topologicalOperator.Simplify(); IConstructMultiPatch innerBuildingConstructMultiPatch = new MultiPatchClass(); innerBuildingConstructMultiPatch.ConstructExtrudeFromTo(BaseZ, InnerBuildingZ, innerBuildingBaseGeometry); IGeometryCollection innerBuildingMultiPatchGeometryCollection = innerBuildingConstructMultiPatch as IGeometryCollection; for (int i = 0; i < innerBuildingMultiPatchGeometryCollection.GeometryCount; i++) { multiPatchGeometryCollection.AddGeometry(innerBuildingMultiPatchGeometryCollection.get_Geometry(i), ref _missing, ref _missing); } IConstructMultiPatch outerBuildingConstructMultiPatch = new MultiPatchClass(); outerBuildingConstructMultiPatch.ConstructExtrudeFromTo(BaseZ, OuterBuildingZ, outerBuildingBaseGeometry); IMultiPatch outerBuildingMultiPatch = outerBuildingConstructMultiPatch as IMultiPatch; IGeometryCollection outerBuildingMultiPatchGeometryCollection = outerBuildingConstructMultiPatch as IGeometryCollection; for (int i = 0; i < outerBuildingMultiPatchGeometryCollection.GeometryCount; i++) { IGeometry outerBuildingPatchGeometry = outerBuildingMultiPatchGeometryCollection.get_Geometry(i); multiPatchGeometryCollection.AddGeometry(outerBuildingPatchGeometry, ref _missing, ref _missing); if (outerBuildingPatchGeometry.GeometryType == esriGeometryType.esriGeometryRing) { bool isBeginningRing = false; esriMultiPatchRingType multiPatchRingType = outerBuildingMultiPatch.GetRingType(outerBuildingPatchGeometry as IRing, ref isBeginningRing); multiPatch.PutRingType(outerBuildingPatchGeometry as IRing, multiPatchRingType); } } return(multiPatchGeometryCollection as IGeometry); }
public static void DrawAxes(IGraphicsContainer3D axesGraphicsContainer3D) { const esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube; const double AxisWidth = 0.25; DrawAxis(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(-10, 0, 0), GeometryUtilities.ConstructPoint3D(10, 0, 0), ColorUtilities.GetColor(255, 0, 0), AxisStyle, AxisWidth); DrawAxis(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(0, -10, 0), GeometryUtilities.ConstructPoint3D(0, 10, 0), ColorUtilities.GetColor(0, 0, 255), AxisStyle, AxisWidth); DrawAxis(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(0, 0, -10), GeometryUtilities.ConstructPoint3D(0, 0, 10), ColorUtilities.GetColor(0, 255, 0), AxisStyle, AxisWidth); DrawEnd(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(10, 0, 0), GeometryUtilities.ConstructVector3D(0, 10, 0), 90, ColorUtilities.GetColor(255, 0, 0), 0.2 * AxisWidth); DrawEnd(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(0, 10, 0), GeometryUtilities.ConstructVector3D(10, 0, 0), -90, ColorUtilities.GetColor(0, 0, 255), 0.2 * AxisWidth); DrawEnd(axesGraphicsContainer3D, GeometryUtilities.ConstructPoint3D(0, 0, 10), null, 0, ColorUtilities.GetColor(0, 255, 0), 0.2 * AxisWidth); }
public static IGeometry GetExample15() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 9.5; const int PointCount = 100; const double UpperZMin = 7; const double UpperZMax = 10; const double LowerZMin = 0; const double LowerZMax = 3; //Extrusion: Circle Shaped Base Geometry Extruded Between Two Different TIN-Based Functional Surfaces IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); //Base Geometry IPointCollection polygonPointCollection = new PolygonClass(); IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = CircleRadius; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent); polygonPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } IPolygon polygon = polygonPointCollection as IPolygon; polygon.Close(); IGeometry baseGeometry = polygon as IGeometry; ITopologicalOperator topologicalOperator = polygon as ITopologicalOperator; topologicalOperator.Simplify(); //Functional Surfaces IEnvelope envelope = new EnvelopeClass(); envelope.XMin = -10; envelope.XMax = 10; envelope.YMin = -10; envelope.YMax = 10; Random random = new Random(); //Upper Functional Surface ITinEdit upperTinEdit = new TinClass(); upperTinEdit.InitNew(envelope); for (int i = 0; i < PointCount; i++) { double x = envelope.XMin + (envelope.XMax - envelope.XMin) * random.NextDouble(); double y = envelope.YMin + (envelope.YMax - envelope.YMin) * random.NextDouble(); double z = UpperZMin + (UpperZMax - UpperZMin) * random.NextDouble(); IPoint point = GeometryUtilities.ConstructPoint3D(x, y, z); upperTinEdit.AddPointZ(point, 0); } IFunctionalSurface upperFunctionalSurface = upperTinEdit as IFunctionalSurface; //Lower Functional Surface ITinEdit lowerTinEdit = new TinClass(); lowerTinEdit.InitNew(envelope); for (int i = 0; i < PointCount; i++) { double x = envelope.XMin + (envelope.XMax - envelope.XMin) * random.NextDouble(); double y = envelope.YMin + (envelope.YMax - envelope.YMin) * random.NextDouble(); double z = LowerZMin + (LowerZMax - LowerZMin) * random.NextDouble(); IPoint point = GeometryUtilities.ConstructPoint3D(x, y, z); lowerTinEdit.AddPointZ(point, 0); } IFunctionalSurface lowerFunctionalSurface = lowerTinEdit as IFunctionalSurface; IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrudeBetween(upperFunctionalSurface, lowerFunctionalSurface, baseGeometry); return(constructMultiPatch as IGeometry); }
public static IGeometry GetExample13() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 3.0; const double BaseZ = 0.0; const double RotationAngleInDegrees = 89.9; //Extrusion: 3D Circle Polyline Extruded Along 3D Vector Via ConstructExtrudeRelative() IPointCollection pathPointCollection = new PathClass(); IGeometry pathGeometry = pathPointCollection as IGeometry; GeometryUtilities.MakeZAware(pathGeometry); IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = CircleRadius; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent, BaseZ); pathPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } pathPointCollection.AddPoint(pathPointCollection.get_Point(0), ref _missing, ref _missing); //Rotate Geometry IVector3D rotationAxisVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0); ITransform3D transform3D = pathGeometry as ITransform3D; transform3D.RotateVector3D(rotationAxisVector3D, GeometryUtilities.GetRadians(RotationAngleInDegrees)); //Construct Polyline From Path Vertices IGeometry polylineGeometry = new PolylineClass(); GeometryUtilities.MakeZAware(polylineGeometry); IPointCollection polylinePointCollection = polylineGeometry as IPointCollection; for (int i = 0; i < pathPointCollection.PointCount; i++) { polylinePointCollection.AddPoint(pathPointCollection.get_Point(i), ref _missing, ref _missing); } ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator; topologicalOperator.Simplify(); //Define Vector To Extrude Along IVector3D extrusionVector3D = GeometryUtilities.ConstructVector3D(10, 0, 5); //Perform Extrusion IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrudeRelative(extrusionVector3D, polylineGeometry); return(constructMultiPatch as IGeometry); }
public static IGeometry GetExample11() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 3.0; const double BaseZ = 0.0; //Extrusion: 3D Circle Polyline Extruded Along 3D Line Via ConstructExtrudeAlongLine() IPointCollection polylinePointCollection = new PolylineClass(); IGeometry polylineGeometry = polylinePointCollection as IGeometry; GeometryUtilities.MakeZAware(polylineGeometry); IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = CircleRadius; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent, BaseZ); polylinePointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } polylinePointCollection.AddPoint(polylinePointCollection.get_Point(0), ref _missing, ref _missing); ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator; topologicalOperator.Simplify(); //Define Line To Extrude Along ILine extrusionLine = new LineClass(); extrusionLine.FromPoint = GeometryUtilities.ConstructPoint3D(-4, -4, -5); extrusionLine.ToPoint = GeometryUtilities.ConstructPoint3D(4, 4, 5); //Perform Extrusion IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrudeAlongLine(extrusionLine, polylineGeometry); //Transform Extrusion Result IPoint centroid = GeometryUtilities.ConstructPoint2D(0.5 * (polylineGeometry.Envelope.XMax + polylineGeometry.Envelope.XMin), 0.5 * (polylineGeometry.Envelope.YMax + polylineGeometry.Envelope.YMin)); ITransform2D transform2D = constructMultiPatch as ITransform2D; transform2D.Move(extrusionLine.FromPoint.X - centroid.X, extrusionLine.FromPoint.Y - centroid.Y); return(constructMultiPatch as IGeometry); }
public static IGeometry GetExample8() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 3.0; const double BaseZ = -10; const double OffsetZ = 5; //Extrusion: 3D Circle Polygon Having Vertices With Varying Z Values, Extruded Relative To Existing // Vertex Z Values Via ConstructExtrude() IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IPointCollection polygonPointCollection = new PolygonClass(); IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = CircleRadius; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); Random random = new Random(); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent, BaseZ + 2 * Math.Sin(random.NextDouble())); polygonPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } IPolygon polygon = polygonPointCollection as IPolygon; polygon.Close(); IGeometry polygonGeometry = polygon as IGeometry; GeometryUtilities.MakeZAware(polygonGeometry); ITopologicalOperator topologicalOperator = polygon as ITopologicalOperator; topologicalOperator.Simplify(); IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrude(OffsetZ, polygonGeometry); return(constructMultiPatch as IGeometry); }