how could I draw a parallel line and perpendicular line of a straight line?

could I make a triangle shape in Julia just like the Pythagoras theorem?

thank you

how could I draw a parallel line and perpendicular line of a straight line?

could I make a triangle shape in Julia just like the Pythagoras theorem?

thank you

1 Like

This can be done using `Plots`

. You can draw a line segment with ends (x_1, y_1) and (x_2, y_2) as follows.

```
using Plots
xs = [x₁, x₂]
ys = [y₁, y₂]
plot(xs, ys)
```

We can do the same thing to draw a triangle. If your triangle has vertices (x_1, y_1),\, (x_2, y_2), and (x_3, y_3) you can draw it doing

```
using Plots
xs = [x₁, x₂, x₃, x₁] # Vertices' x-component
ys = [y₁, y₂, y₃, y₁] # Vertices' y-component
plot(xs, ys)
```

The triangle has three sides so at least we need four points to draw the three of them, that’s why `x₁`

and `y₁`

are repeated at the start and end of `xs`

and `ys`

.

The triangle can also be drawn using `Compose`

:

```
using Compose
vertices = [(x₁, y₁), (x₂, y₂), (x₃, y₃)]
compose(context(), polygon(vertices))
```

1 Like