2: 2015-03-26 (木) 22:01:26 osinko |
3: 2015-03-30 (月) 03:42:37 osinko |
| #contents | | #contents |
| **正射影 [#ad6e31b3] | | **正射影 [#ad6e31b3] |
- | \(\mathbf{a}\)に\(\mathbf{b}\)を射影したベクトル\(\mathbf{p}\)を求めたい。この場合の射影ベクトルを求める式は以下になる | + | \(\mathbf{a}\)に\(\mathbf{b}\)を射影した\(\mathbf{p}\)を求めたい。この場合の射影ベクトルを求める式は以下になる |
| + | &font(Red){\(\mathbf{ p }=\frac { \mathbf{a}\cdot \mathbf{b} }{ \mathbf{a}\cdot \mathbf{a} } \mathbf{a}\)}; |
| | | |
- | \(\mathbf{b}\)の単位ベクトルを\(\mathbf{e}=\frac { \mathbf{b} }{ \left| \mathbf{b} \right| }\) として射影ベクトルは\(\left( \mathbf{a}\cdot \mathbf{e} \right) \mathbf{e}\)で求まる | + | #code(csharp){{ |
| + | using UnityEngine; |
| + | using System.Collections; |
| + | |
| + | public class projection1 : MonoBehaviour |
| + | { |
| + | Vector3 a, b, proj, proj2; |
| + | |
| + | void Start () |
| + | { |
| + | a = new Vector3 (10, 4); |
| + | b = new Vector3 (3, 7); |
| + | |
| + | proj = Vector3.Project (b, a); |
| + | proj2 = (Vector3.Dot (a, b) / Vector3.Dot (a, a)) * a; |
| + | |
| + | print ("正射影unity標準機能=" + proj + " 正射影自分で計算=" + proj2); |
| + | } |
| + | } |
| + | }} |
| + | |
| + | **証明 [#ndfd6147] |