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

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

问题描述

我正在尝试为一个对象设置动画,假设它是一辆汽车.我希望它从点开始

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 Frame.

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 是因为它们很容易在任何一点减去切线 - 只需将其他 2 个近点与当前点之间的(向量)差值.(假设你在 t,选择 t-epsilont+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天全站免登陆