三维空间:以下的方向,一个对象被指向,使用鼠标指针 [英] 3D space: following the direction that an object is pointing towards, using the mouse pointer

查看:170
本文介绍了三维空间:以下的方向,一个对象被指向,使用鼠标指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于相机朝向,并在3D空间中的三维对象的方向/方向矢量的方向的三维矢量,我怎么能计算出2维斜坡鼠标指针,必须按照屏幕上的顺序在视觉上被沿着所述物体的方向移动

Given the 3D vector of the direction that the camera is facing and the orientation/direction vector of a 3D object in the 3D space, how can I calculate the 2-dimensional slope that the mouse pointer must follow on the screen in order to visually be moving along the direction of said object?

基本上,我希望能够点击箭头并使其来回移动通过拖动,但只有当鼠标指针拖动(大致)沿着箭头,即长度的方向,它的指向。

Basically I'd like to be able to click on an arrow and make it move back and forth by dragging it, but only if the mouse pointer drags (roughly) along the length of the arrow, i.e. in the direction that it's pointing to.

谢谢

推荐答案

我不知道我100%的明白你的问题。你介意张贴图?

I'm not sure I 100% understand your question. Would you mind posting a diagram?

您可能会发现这些感兴趣。我回答previous问题<一href="http://stackoverflow.com/questions/8633034/basic-render-3d-perspective-projection-onto-2d-screen-with-camera-without-openg/8758027#8758027">calculate当地XYZ轴赋予了相机的方向(看)载体,也是一个问题<一href="http://stackoverflow.com/questions/8323161/wpf3d-how-to-manipulate-objects-in-a-plane-parallel-to-the-camera/8744083#8744083">translate平行于相机的在一个平面上的对象。

You might find these of interest. I answered previous questions to calculate a local X Y Z axis given a camera direction (look at) vector, and also a question to translate an object in a plane parallel to the camera.

这两个例子都使用向量的点积,的向量积来计算所需要的载体。在您的例子中,向量的点积也可以用于输出的角度两个向量之间一旦你有找到他们。

Both of these examples use Vector dot product, Vector cross product to compute the required vectors. In your example the vector dot product can be also used to output the angle between two vectors once you have found them.

这篇关于三维空间:以下的方向,一个对象被指向,使用鼠标指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆