计算沿路径的旋转 [英] Calculating rotation along a path

查看:93
本文介绍了计算沿路径的旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为一个物体设置动画,比如说它是一辆汽车.我要它从点开始

I am trying to animate an object, let's say its a car. I want it go from point

x1,y1,z1

指向 x2,y2,z2 .它会移动到这些点,但似乎是漂移,而不是指向运动方向.所以我的问题是:如何在我的updateframe()事件中解决此问题?您能指出我一些好的资源的方向吗?

to point x2,y2,z2 . It moves to those points, but it appears to be drifting rather than pointing in the direction of motion. So my question is: how can I solve this issue in my updateframe() event? Could you point me in the direction of some good resources?

谢谢.

推荐答案

首先,您如何表示这条路?

First off how do you represent the road?

我最近确实做了这件事,并且在路途中使用了 Catmull-Rom 样条线.要使对象定向并使其遵循样条曲线路径,您需要从沿样条线移动的 t 中插入当前的 x,y,z 位置,然后沿其定向"Frenet坐标系"或"Frenet框架" 用于该特定位置.

I recently done exactly this thing and I used Catmull-Rom splines for the road. To orient an object and make it follow the spline path you need to interpolate the current x,y,z position from a t that walks along the spline, then orient it along the Frenet Coordinates System or Frenet Frame for that particular position.

基本上,每个点都需要3个向量:切线,法线和双法线.切线将是您希望物体(汽车)指向的实际方向.

Basically for each point you need 3 vectors: the Tangent, the Normal, and the Binormal. The Tangent will be the actual direction you will like your object (car) to point at.

我之所以选择Catmull-Rom,是因为它们很容易在任意点扣除切线-只需使当前其他两个近点之间的(向量)差即可. (假设您在 t ,选择 t-epsilon t + epsilon -epsilon是一个足够小的常数).

I choose Catmull-Rom because they are easy to deduct the tangents at any point - just make the (vector) difference between 2 other near points to the current one. (Say you are at t, pick t-epsilon and t+epsilon - with epsilon being a small enough constant).

对于其他2个向量,可以使用此迭代方法-也就是说,您从一端的一组已知向量开始,然后根据每个 updateframe()的前一个向量来处理一组新向量. ).

For the other 2 vectors, you can use this iterative method - that is you start with a known set of vectors on one end, and you work a new set based on the previous one each updateframe() ).

这篇关于计算沿路径的旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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