# Draw cones using WPF and C# This example shows how to draw cones in WPF and C#. The program uses a method very similar to the one used by the example Draw cylinders using WPF and C#. The picture on the right shows the approach used by the previous example to draw a cylinder. It starts with the endpoint (green). It then adds a vector perpendicular to the axes to get the point p1 on the cylinder’s base. Next it adds the vector axis to that point to get the point p2 on the other end of the cylinder. The program generates the cylinder by connecting the points properly. To create a truncated cone, this example use the slightly different approach shown on the left. It adds vector v1 to the first end point (green) to get the point p1. It then adds a different vector v2 to the other end point (red) to get the corresponding point on the other end of the cone.

To generate the vectors v1, the program finds two vectors perpendicular to the axis in the plane of the cone’s base. It then multiples those vectors my the cosine and sine of an angle theta as theta runs from 0 to 2π. It generates the vectors v2 similarly.

The AddCone method has the following signature:

```private void AddCone(MeshGeometry3D mesh, Point3D end_point,

Its parameters are:

• mesh – The mesh object that should contain the new cone.
• end_point – The center of one of the cone’s faces. (Green in the pictures above.)
• axis – The cone’s axis.
• num_sides – The number of polygons that should be used around the cone’s sides.

To generate a complete cone instead of a truncated cone (like the blue cone in the picture at the top of the post), just set radius1 or radius2 to 0.     