Jump to content
  • Advertisement
Sign in to follow this  
ptitjulien

building an orthogonal 3D basis out of a single hermite spline?

This topic is 3333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, Well i've been stuck on this problem for a while... I'm trying to build a path where mesh can move along, i'd like the mesh to head towards the tangent of the spline at all times. However i'm stuck with "discontinuity" problems, my basis is sunddenly switching 90 degrees in random directions at half of the hermite knot distances it seems... :/ Here is the code that i use currently: ________________________________________________________ vec3d BaseZ = position->getD( t ); // first derivate vec3d BaseX = position->getD2( t ); // second derivate vec3d BaseY = BaseZ ^ BaseX; BaseX.normalize(); BaseY.normalize(); BaseZ.normalize(); BaseZ = BaseX ^ BaseY; BaseX = BaseY ^ BaseZ; BaseY = BaseZ ^ BaseX; matrix3 baseMatrix; baseMatrix.set( BaseX, BaseY, BaseZ ); baseMatrix = baseMatrix.inverse(); ________________________________________________________ any help or links really appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
After normalization, BaseX and BaseY are unit length vectors but they are not necessarily perpendicular. BaseZ = Cross(BaseX,BaseY) will be a unit length vector *only when BaseX and BaseY are unit length*. After your three cross product evaluations, the three vectors are mutually perpendicular but not necessarily unit length.

If you have to use your approach, the last cross product is not necessary:

BaseZ = position->getD(t);
BaseX = position->getD2(t);
BaseY = BaseZ ^ BaseX;
BaseZ = BaseX ^ BaseY;
BaseX = BaseY ^ BaseZ;
BaseX.normalize();
BaseY.normalize();
BaseZ.normalize();


This produces unit-length and mutually orthogonal vectors.

Typical approaches to a "coordinate frame" along a curve. First is the Frenet-Serret frame. The tangent T(t) = X'(t)/|X'(t)|. The normal and binormal are computed using curvature and torsion. Second is a frame based on having a preferred "up" vector U, where you are required never to allow the tangent to point in the up or down directions. Compute T(t) as in the Frenet-Serret frame. Compute binormal B(t) = Cross(T(t),U)/Length(Cross(T(t),U)). Compute normal N(t) = Cross(B(t),T(t)).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!