e****c 发帖数: 10 | 1 这两天再写3D 游戏,遇到数学问题请教大家。
有一个小圆盘,怎么样转动使它的中心与摄像机位置的连线总得与小圆盘平面垂直。
晓圆盘的位置已知,切静止不动,小圆盘的初始位置可以假设为(0,0,1)Z轴正向。
问题就是当相机移动到某个位置(相机的位置已知),小圆盘绕什么轴 转动多大角, 使
得小圆盘的平面总与它与相机的连线垂直 | h**********c 发帖数: 4120 | 2 you problem is not mathematical description adequately.
but I make the following assumptions.
the camera move from (a,b,c) to (m,n,q)
the disk is at (r,s,t) up vector vd=(u,v,w)
v1 = (a-r,b-s,c-t)
v2 = ((m-r,n-s,q-t)
v3 = cross(v1,v2)
v4 = cross(vd,v3)
theta = dot (v3,vd)/(norm(v3)*norm(vd))
Rotate disk about v4 with angle theta. calculate theta by the dot product
arccos or sth else.
This is a kind suggestion, no reliability. |
|