高校数学​/三角関数

Unity学習帳2冊目高校数学 / 三角関数

三角比の定義 anchor.png

直角三角形は90度の直角と鋭角\(\theta\)(シータ)とで構成される。三辺は各々以下のように定義される。鋭角\(\theta\)は任意に決めることが出来る事に留意。証明では時にこの角を切り替える。それに従って対辺と隣辺が入れ替わる
trigona.png

  • 直角に向かい合う辺を斜辺(hypotenuse)
  • \(\theta\)に向かい合う辺を対辺(opposite)
  • 残りの辺(θから直角に向かう辺)を隣辺(adjacent)

三角関数、sin(サイン:正弦:せいげん)、cos(コサイン:余弦:よげん)、tan(タンジェント:正接:せいせつ)は、この各辺の長さを比で表すので三角比と呼ばれる
\(\sin { \theta } =\frac { 対辺 }{ 斜辺 } \quad ,\quad \cos { \theta } =\frac { 隣辺 }{ 斜辺 } \quad ,\tan { \theta } =\frac { \sin { \theta } }{ \cos { \theta } } =\frac { 対辺 }{ 隣辺} \)
この分数の関係式は頭文字の英語の筆記体の書き順で憶えると良い。分母のほうから辺の長さを割り当てる
sin,cosは斜辺が母(分母)と憶える

二つの角が同じ角度になる三角形同士は相似と言えるので、どんなに大きさが変わっても各辺の「比」は変わらない
trigonb.png
比は変わらないので斜辺rの長さを基準としてsinθやcosθの長さが導き出される式へと変形できる

sincos2.png\(r\cos { \theta } =r\frac { x }{ r } \quad \quad \rightarrow \quad \quad x=r\cos { \theta } \\ r\sin { \theta } =r\frac { y }{ r } \quad \quad \rightarrow \quad \quad y=r\sin { \theta } \)

たとえばθ=30°斜辺rの長さが3.5の時のxとyの長さを知りたいときunityで計算するには以下のようなコードになる

<unityのコード例>

Everything is expanded.Everything is shortened.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 
 
 
 
-
|
-
|
|
|
|
|
|
!
!
using UnityEngine;
using System.Collections;
 
public class trigon1 : MonoBehaviour
{
        void Start ()
        {
                float r, theta, x, y;
                r = 3.5f;
                theta = 30 * Mathf.Deg2Rad;    //°(単位度)からラジアンへ変換
                x = r * Mathf.Cos (theta);
                y = r * Mathf.Sin (theta);
                print ("r=" + r + " θ=" + theta + " x=" + x + " y=" + y);
        }
}

出力
r=3.5 θ=0.5235988 x=3.031089 y=1.75


tanθは一次関数式の傾きとしても取り扱える
e1c2780d9457ca20ed35d48d38814082.png

Page Top

ラジアン(RadianAngles:弧度法) anchor.png

三角関数では角の大きさを測る引数に弧の長さの実数であるラジアンを利用する。日本人が日常で角度を測る際、分度器などで使う°はオイラー角(EulerAngles)と呼ばれる単位値であり実数ではない(メートルやキログラム等の単位値と同類)
1回転 = 360° = \(2\pi\)
通常、角はギリシャ文字θ(シータ)を用いて表される。aを°によるオイラー角度とするとラジアンを求める単位変換式は以下になる
78feedc804f38212694e84d9d5210330.png
基本的にLの長さによる単位の無い実数となり y=cos(x)等の実数の関数式に対して比の値として扱える事になる(だから三角関数に対してラジアンが利用される)。unityでMathf.sin関数に喰わせる引数もラジアンでありオイラー角ではないので注意。また相互変換には上記の式を利用すると便利だが\(\frac { \pi }{ 180 } \)は定数なのでunityにはMathf.Deg2Radなどの専用のプロパティが用意されている

Page Top

三角関数の定義 anchor.png

ラジアンと単位円、三角比を用いた三角関数の定義。原点を中心とした半径1の円周上にあってx軸正の方向から反時計回りにラジアン角θを取った座標位置を(cosθ,sinθ)とする。この定義よりθはオイラー角90°を超える角度が扱える事となる。三角形OABは常に直角三角形になるので「三角比」の考えと同時に「三平方の定理」が適用できる(尚、半径1の円を単位円と呼ぶ)
0cded19e12a181bf3e8388dbce4eb67e.png
このcos(x)とsin(x)をグラフで描くと以下の様な波のグラフになる
sincos1.png
この実際の値の動きを視覚的に確認できるプログラムを作りました。unity_webプレーヤーで実際に触って挙動を確認できます
三角関数プレーヤー_for_Unity

Everything is expanded.Everything is shortened.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 
 
 
 
-
|
-
|
|
|
!
!
using UnityEngine;
using System.Collections;
 
public class trigon2 : MonoBehaviour
{
        void Start ()
        {
                float x = Mathf.Cos (60 * Mathf.Deg2Rad);
                float y = Mathf.Sin (60 * Mathf.Deg2Rad);
                print (Mathf.Pow (x, 2) + Mathf.Pow (y, 2));     //三平方の定理により1になる事が確認できる
        }
}
Page Top

負角、余角の公式 anchor.png

θを時計回りに進めると負角(-)となり、以下の負角の公式が利用できる
\(\cos { (-\theta ) } =cos\theta \quad ,\quad \sin { (-\theta ) } =-\sin { \theta } \)
直角\(\frac { \pi }{ 2 } \)からθを引いた余りの角を余角と呼び、以下の余角の公式が利用できる
\(\cos { \left( \frac { \pi }{ 2 } -\theta \right) } =\sin { \theta } \quad ,\quad \sin { \left( \frac { \pi }{ 2 } -\theta \right) = } \cos { \theta } \)
f251ae8248eb7f58752c4597e59b4629.png
※unityのMathfクラスsin,cos関数ではマイナスの引数でも上記の公式を内部で処理し正確に値を算出します

Page Top

atan(アークタンジェント:逆正接) anchor.png

atan は tan の逆関数になる(つまり傾きから角度を得る)。傾きはわかっているが角度が判らない時に使うと便利。逆算が可能なのでゲームコードで利用される頻度は比較的高い。返り値はラジアン角θとなる
\(\tan { \theta } =\frac { \sin { \theta } }{ \cos { \theta } } =\frac { y }{ x } \quad \quad \Leftrightarrow \quad \quad \arctan { \left( \frac { y }{ x } \right) } =\theta \)
arctanは幾つかの表現方法があり\(\arctan { \left( \frac { y }{ x } \right) }\) も\(\tan ^{ -1 }{ \left( \frac { y }{ x } \right) } \)も同じ意味となる
unityのコードではAtanAtan2で表される

<unityのコード例>

Everything is expanded.Everything is shortened.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
 
 
 
 
-
|
|
-
|
|
|
|
|
|
|
|
|
|
|
!
!
using UnityEngine;
using System.Collections;
 
public class Trigon3 : MonoBehaviour
{
        float theta, x, y, tan, arctan, arctan2;
        void Start ()
        {
                theta = 30f * Mathf.Deg2Rad;
                x = Mathf.Cos (theta);
                y = Mathf.Sin (theta);
                tan = Mathf.Tan (theta);
                arctan = Mathf.Atan (tan) * Mathf.Rad2Deg;
                arctan2 = Mathf.Atan2 (y, x) * Mathf.Rad2Deg;
                print ("cos=" + x + "  sin=" + y + "  tan=" + tan + "  arctan=" + arctan + "  arctan2=" + arctan2);
 
                Vector2 vec = Vector2.right;
                vec = Quaternion.AngleAxis (30, Vector3.forward) * vec;
                print ("30°回転させたベクトル=" + vec + "  arctan関数で逆算した値=" + Mathf.Atan2 (vec.y, vec.x) * Mathf.Rad2Deg);
        }
}

出力
cos=0.8660254 sin=0.5 tan=0.5773503 arctan=30 arctan2=30
30°回転させたベクトル=(0.9, 0.5) arctan関数で逆算した値=30


Page Top

有名なsin,cos値 anchor.png

最低限、暗記しておいた方が良いsin,cos値

cos(0°)1sin(0°)0
cos(30°)√0.75 = 0.866~sin(30°)√0.25= 0.5
cos(45°)√0.5= 0.7071~sin(45°)√0.5= 0.7071~
cos(60°)√0.25= 0.5sin(60°)√0.75 = 0.866~
cos(90°)0sin(90°)1

45°を境にsin,cosの関係が対称になっている

上の表から以下の式で三平方の定理が成立している事が確認できる
\(\cos ^{ 2 }{ (30) } +\sin ^{ 2 }{ (30) } =1\quad \quad \rightarrow \quad { \quad 0.866 }...^{ 2 }+{ 0.5 }^{ 2 }=1\)

Page Top

三角関数の表記注意点 anchor.png

三角関数同士の掛算では以下の様に表記する必要がある
\(\sin { A } \times \sin { B } =\sin { A } \sin { B } \)
sinABの様な書き方はNGなので注意

累乗表記は
\(\sin { \theta } \times \sin { \theta } =\sin ^{ 2 }{ \theta } \)
のように関数側の右肩に書く事が約束となっている



添付ファイル:

トップ   差分 バックアップ 複製 名前変更 リロード   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom
Last-modified: 2015-03-25 (水) 11:57:39 (JST) (3322d) by osinko