LoginSignup
4
6

More than 5 years have passed since last update.

Unityで三角関数#1

Last updated at Posted at 2015-11-03

sinθのθから度を求める方法。
逆三角関数からラジアンを求めてMathf.Rad2Degで度を求めました。

using UnityEngine;
using System.Collections;

public class ArcsinTest : MonoBehaviour {

    // Use this for initialization
    void Start () {
        //アークサインからラジアンを求める
        print (Mathf.Asin(0.5f));
        //ラジアンから度に変換します
        print (Mathf.Asin(0.5f)*Mathf.Rad2Deg);
    }

}

結果:30度だという事がわかります。
スクリーンショット 2015-11-03 12.27.14.png

(補足)
サイン、コサイン、タンジェント
これでsinθ、cosθ、tanθを求めます。
1.jpg

例題
2.png
sinθは0.38.......になります。度数は約22度になります。
早見表
3.png

三角関数表
http://emath.s40.xrea.com/ydir/Wiki/index.php?%BB%B0%B3%D1%B4%D8%BF%F4%C9%BD

おまけ
4.png

以下の値を求める時に余弦定理を使います。
a^2 = b^2+c^2-2bccosθ
スクリーンショット 2015-11-03 18.20.12.png

C^2 = 8^2+6^2 - 2*6*8*cos60
C = √64+36-2*48*0.5
C = √52 = 7.211

余弦定理の補足
6.png

ラジアン補足
円周の長さ=2πr(πは3.14 rは半径)
単位円では半径は1
90度:π/2 180度π

Unityで確認してみます。
```csharp
using UnityEngine;
using System.Collections;

public class ArcsinTest : MonoBehaviour {

// Use this for initialization
void Start () {
    //πから角度を求める
    print (3.14F*Mathf.Rad2Deg);
    print (3.14F/2*Mathf.Rad2Deg);
}

}
```
スクリーンショット 2015-11-03 19.11.35.png

-

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6