In this article, we will learn how to make a triangle in OpenSCAD using various methods. If you have been using OpenSCAD for a while, you might have noticed that there is no proper function to create a triangle in OpenSCAD. Well, we can use some other methods like a cube, polygon, or cylinder to create a make triangle in OpemSCAD.

Learn how to create a hexagon in OpenSCAD using different methods.

## Make a Triangle in OpenSCAD Through Different Methods.

Although, there is no specific function in OpenSCAD to make triangles, but we can use other methods and manipulate them accordingly to make a triangle in OpenSCAD. In this section, we will mainly use the following methods to create a triangle in OpneSCAD.

- Using the cylinder method to make a triangle in OpenSCAD
- Using the polygon method to make a triangle in OpenSCAD
- Using cubes to make a triangle in OpenSCAD

### Use the Cylinder Method to Make a Triangle in OpenSCAD

We know that the cylinder method is used to make cylinders where we have to specify the radius and height of the cylinder. However, we can use the same method to make a triangle in OpenSCAD as well. There is an optional parameter in the cylinder method, which is to decide how many fragments we want to have in a cylinder. For example, let us have a cylinder with 20 fragments.

// cylinder with radius of 3 cylinder(r=10, h=3, $fn=20);

Output:

As you can see we created a cylinder with 20 fragments. If we will reduce the fragments to 3, we will be able to make a triangle as shown below:

// cylinder with radius of 3 cylinder(r=10, h=3, $fn=3);

Output:

As you can see, we created a triangle in OpenSCAD using the cylinder method.

You can change the color of the object by specifying the color element and putting the triangle inside it as shown below:

//changing the color color("green"){ // cylinder with radius of 3 cylinder(r=10, h=3, $fn=3); }

Output:

As you can see, we have changed the color of the triangle.

### Make a Triangle in OpenSCAD Using Polygon Method.

The polygon method is used to create various shapes in OpenSCAD. We need to provide the coordinates of the polygon. For example, we can provide the following points to create a triangle.

//creating triangle polygon(points=[[0,0],[10,0],[0,10]], paths=[[0,1,2]]);

Output:

As you can see, we have created a small triangle using the polygon method in OpenSCAD.

We can play with this method and create different triangles. For example, let us create a triangle that is empty from the inside as shown below:

polygon(points=[[0,0],[100, 0],[0,100],[10,10],[80,10],[10,80]], paths=[[0,1,2],[3,4,5]]);

Output:

As you can see, we have created a triangle that is empty from the inside.

### Make a Triangle in OpenSCAD Using Cube() Method

We know that cube() method in OpenSCAD is used to make cubes but we can use this method to create a triangle as well.

We will create cubes and then use the difference() method to cut the pieces of the cube and make it a triangle. First, create a cube as shown below:

//creating a cube cube([10, 10, 2]);

Output:

Now, we will create one more cube and rotate it 45 degrees.

//creating a cube cube([10, 10, 2]); //rotating the cube rotate([0, 0, 45]){ #cube([20, 20, 2]); }

Output:

Now we can take the difference and we will be left with a triangle as shown below:

difference(){ //creating a cube cube([10, 10, 2]); //rotating the cube translate([0, 0, -0.2]){ rotate([0, 0, 45]){ cube([20, 20, 3]); } } }

Output:

As you can see, we have created a triangle in OpenSCAD.

## Summary

In this short article, we learned how we can make a triangle in OpenSCAD using three different methods. We created triangles using cylinder, cube, and polygon methods. Hopefully, you had learned something new from our content. If you have any questions or suggestions, please let us know through comments.