質問編集履歴
4
cosの図の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -156,7 +156,9 @@
|
|
156
156
|
|
157
157
|
### 追記②
|
158
158
|
|
159
|
+
cosの図が間違ってたので修正しました。
|
160
|
+
|
159
|
-
![イメージ説明](
|
161
|
+
![イメージ説明](d64c2bea2626ddfcc07e191a53dd90e5.png)
|
160
162
|
|
161
163
|
|
162
164
|
|
3
メモ追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -157,3 +157,15 @@
|
|
157
157
|
### 追記②
|
158
158
|
|
159
159
|
![イメージ説明](098d7e7b7c2f5ce645a09fe26e3e587a.png)
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
### メモ
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
nDir・forward = cosθ
|
168
|
+
|
169
|
+
v=nDir/cosθ
|
170
|
+
|
171
|
+
v=nDir/nDir・forward
|
2
図の挿入
test
CHANGED
File without changes
|
test
CHANGED
@@ -151,3 +151,9 @@
|
|
151
151
|
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //9.727413
|
152
152
|
|
153
153
|
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
### 追記②
|
158
|
+
|
159
|
+
![イメージ説明](098d7e7b7c2f5ce645a09fe26e3e587a.png)
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -111,3 +111,43 @@
|
|
111
111
|
なぜ、cubeViewport.xが0.8fに、cubeViewport.yが0.6fにならないのでしょうか?
|
112
112
|
|
113
113
|
誤差にしては大き過ぎると思いました。
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
### 追記
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
```C#
|
122
|
+
|
123
|
+
Vector3 worldpos = Camera.main.ViewportToWorldPoint(new Vector3(0.8f, 0.6f, 5f));
|
124
|
+
|
125
|
+
cube.transform.position = worldpos;
|
126
|
+
|
127
|
+
Vector3 cubeViewport = Camera.main.WorldToViewportPoint(cube.transform.position);
|
128
|
+
|
129
|
+
Debug.Log("cubeViewport.x:" + cubeViewport.x); //0.7999997
|
130
|
+
|
131
|
+
Debug.Log("cubeViewport.y:" + cubeViewport.y); //0.5999997
|
132
|
+
|
133
|
+
Debug.Log("cubeViewport.z:" + cubeViewport.z); //5
|
134
|
+
|
135
|
+
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //6.727412
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
Vector3 dir = cube.transform.position - Camera.main.transform.position;
|
140
|
+
|
141
|
+
cube.transform.position = cube.transform.position + Vector3.Normalize(dir)*3;
|
142
|
+
|
143
|
+
Vector3 cubeViewport2 = Camera.main.WorldToViewportPoint(cube.transform.position);
|
144
|
+
|
145
|
+
Debug.Log("cubeViewport2.x:" + cubeViewport2.x); //0.7999997
|
146
|
+
|
147
|
+
Debug.Log("cubeViewport2.y:" + cubeViewport2.y); //0.5999997
|
148
|
+
|
149
|
+
Debug.Log("cubeViewport2.z:" + cubeViewport2.z); //7.229684
|
150
|
+
|
151
|
+
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //9.727413
|
152
|
+
|
153
|
+
```
|