楕円

※ @wikiのtex記法は大きすぎるのですが,{\scriptstyle }で囲むと小さく表示できます。

◆一般式・標準形
◆一般式と標準形の相互変換


一般式・標準形

平行移動・回転の変換それぞれの方程式の 求め方・一覧は:楕円 - 方程式一覧

一般式
楕円を表す方程式は,次のような二次曲線(∈二次方程式)です。
※ 二次方程式が二次曲線である条件については:楕円 - 楕円である条件

 {\scriptstyle   Ax^2 + By^2 + Cxy + Dx + Ey + F\ =\ 0,\ 4AB-C^2 > 0  }

標準形
また,楕円の方程式はしばしば次のような「標準形」で表されます。
※ 平行移動量(中心):(x0,y0),回転量:θ

 {\scriptstyle   \frac{ \{ (x-x_0)\cos\theta + (y-y_0)\sin\theta \}^2 }{ {r_x}^2 } + \frac{ \{ (x-x_0)\sin\theta - (y-y_0)\cos\theta \}^2 }{ {r_y}^2 } = 1,\ r_x > 0,\ r_y > 0  }


一般式⇔標準形 相互変換

表記をにするため,rx=a, ry=bとしてます。

標準形 ⇒ 一般式
標準形を展開した結果です。

 {\scriptstyle  A\ =\ b^2\cos^2\theta + a^2\sin^2\theta  }
 {\scriptstyle  B\ =\ b^2\sin^2\theta + a^2\cos^2\theta  }
 {\scriptstyle  C\ =\ 2(b^2-a^2)\sin\theta\cos\theta  }
 {\scriptstyle  D\ =\ -2{x_0}( b^2\cos^2\theta + a^2\sin^2\theta ) -2{y_0}( b^2-a^2 )\sin\theta\cos\theta  }
 {\scriptstyle  E\ =\ -2{y_0}( b^2\sin^2\theta + a^2\cos^2\theta ) -2{x_0}( b^2-a^2 )\sin\theta\cos\theta  }
 {\scriptstyle  F\ =\ {x_0}^2(b^2\cos^2\theta+a^2\sin^2\theta) + {y_0}^2(b^2\sin^2\theta+a^2\cos^2\theta)  }
 {\scriptstyle  ,\ \ \ \ \ \ \ + 2{x_0}{y_0}(b^2-a^2)\sin\theta\cos\theta  }
 {\scriptstyle  ,\ \ \ \ \ \ \ - a^2b^2  }

一般式 ⇒ 標準形
導出します:楕円 - 一般式to標準形の変換導出

 {\scriptstyle   x_0=\ \frac{CE-2BD}{4AB-C^2}  }
 {\scriptstyle   y_0=\ \frac{CD-2AE}{4AB-C^2}  }
 {\scriptstyle   \theta \ =\ \frac{1}{2}\tan^{-1}\frac{C}{A-B}  }
  ※ arctan2を使わず,θ = (A-B == 0) ? 0 : arctan( C/(A-B) )/2;でいけました。
 {\scriptstyle   a\ =\ \sqrt{-\frac{K}{A'}}  }
 {\scriptstyle   b\ =\ \sqrt{-\frac{K}{B'}}  }

ただし,
 {\scriptstyle   K\ =\ A{x_0}^2 + B{y_0}^2 + Cx_0y_0 + Dx_0 + Ey_0 + F  }
 {\scriptstyle   A'\ =\ A \cos^2\theta + B \sin^2\theta + C \sin\theta \cos\theta  }
 {\scriptstyle   B'\ =\ A \sin^2\theta + B \cos^2\theta - C \sin\theta \cos\theta  }


端点・座標

楕円の描画は,楕円の端を求めx,y軸それぞれに沿ってもう片方の座標を算出することで可能です。
導出過程・結果は:楕円 - 座標・端点

効率的な描画は,3Dモデル描画等の方法を調べればよいのかもしれません。



最終更新:2013年08月08日 19:40