Shapes seem like an obvious topic. Since they are ubiquitous, we take them for granted. Many tools provide ways to draw shapes, and many of them are pretty simple, like these functions in p5.js.
形は一見単純なテーマに見えます。形はどこにでもあるので、その存在を当たり前のように考えがちです。多くのツールが図形を描く機能を提供しており、下のp5.jsの関数のように、その多くはシンプルな仕組みです。
https://codepen.io/kynd/pen/EajxeEm?editors=0010
But as soon as we look more closely, things get complicated. In fact, there are infinite ways to define and draw shapes, and most of the shapes in the wild, from industrial products to nature, have so many nuances.
しかし、詳しく見ようとすると、物事はそれほど単純ではないことに気づきます。実際、図形を定義し描画する方法は無限にあり、工業製品から自然界まで、身の周りの形のほとんどには、様々な繊細な特徴があります。
Let's start with geometric shapes that are (relatively) easier to define mathematically and handle with code.
(比較的)数学的に定義しやすく、コードで扱いやすい単純な幾何学的図形から始めましょう。
It is easy to draw line segments, circles, etc. in various environments including HTML canvas. However, it is not so easy to draw figures like those in geometry textbooks. Even a simple operation such as drawing a circle around the intersection of two straight lines requires a bit of calculation. The ability to draw a picture and the ability to handle geometry mathematically are two different things. Of course, there are many well-designed libraries out there, but it is also a good learning experience to implement basic functions by yourself. Well it was at least for myself.
HTML Canvasを始めとする様々な環境では簡単に線分や円を描くことができます。ところが幾何学の教科書に出てくるような図形を描くのは意外と難しくて、2直線の交点を中心に円を描くといったシンプルな操作にもちょっとした計算が必要になります。絵を描く機能と数学的に図形を扱う機能は別物なのです。もちろん世の中にはよく出来たライブラリがたくさんあるのですが、自分で基本的な機能を実装してみるのも良い勉強になります(なりました)。