<p>The main part of it is simply Pythagoras's Theorem. The square root gives the length of the central line segment (which is the hypotenuse of a triangle formed by the change in x and change in y). The ratio between the hypotenuse and the change in x is the same as the ratio between the line width and the line width in y (they are similar triangles). Dividing by two is because $w_y$ is the half-width, not the full width. The -1 doesn't appear to make sense in a continuous context, so I assume it's to make sure the number of pixels is rounded down as part of the division. This prevents the line from jumping in thickness when it crosses a pixel boundary.</p>

CC BY-SA 3.0
2017-08-25T13:59:42.973Z
2017-08-25T13:59:42.973Z
Dan Hulme
<p>How is this 'w<sub>y</sub>' equation for thick line segment derived?</p>

<p><a href="https://i.sstatic.net/EmgKN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EmgKN.png" alt="Thick line segment"></a></p>

<p><a href="https://i.sstatic.net/73syB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/73syB.png" alt="equation"></a></p>

<vector-graphics><pixel-graphics>
Thick Line segment
jeet rabari
# Thick Line segment

(Asked by: username_0 on 2017-08-25)

How is this 'wy' equation for thick line segment derived?

[![Thick line segment](https://i.sstatic.net/EmgKN.png)](https://i.sstatic.net/EmgKN.png)

[![equation](https://i.sstatic.net/73syB.png)](https://i.sstatic.net/73syB.png)

**Tags:** vector-graphics, pixel-graphics


---

## 1 answers

### Answer by username_1 on 2017-08-25. Score: 3 | Accepted answer

The main part of it is simply Pythagoras's Theorem. The square root gives the length of the central line segment (which is the hypotenuse of a triangle formed by the change in x and change in y). The ratio between the hypotenuse and the change in x is the same as the ratio between the line width and the line width in y (they are similar triangles). Dividing by two is because $w\_y$ is the half-width, not the full width. The -1 doesn't appear to make sense in a continuous context, so I assume it's to make sure the number of pixels is rounded down as part of the division. This prevents the line from jumping in thickness when it crosses a pixel boundary.


---

