3D空间:按照对象指向的方向,使用鼠标指针 [英] 3D space: following the direction that an object is pointing towards, using the mouse pointer

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

问题描述

给定相机所面向的方向的3D矢量和3D空间中3D对象的方向/方向矢量,我如何计算鼠标指针必须按照屏幕顺序的二维斜率在视觉上沿着对象的方向移动?

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?

您可能会发现这些兴趣。我回答了以前的问题到计算一个本地XYZ轴给定相机方向(查看)向量,并且还有一个问题到在与摄像机平行的平面中翻译对象

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.

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

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