# The Spherical Interpolator doesn't have enough time to complete its task

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

## Recommended Posts

When the t = 1 is reached, the agent still cannot get to the correct orientation.....

I am not sure should I put the initial direction vector at (0,0,1), because I calculate the directional vector every frame in

the world matrix in the Update function, the directional vector is then extracted as

m[13], m[23], m[33] in that frame.

D3DXQUATERNION qFinal, qStart, qEnd;
float fOldDir = l_transform->m_MotionInfo.fStartDir;
float fNewDir = l_transform->m_MotionInfo.fEndDir;

D3DXQuaternionRotationYawPitchRoll(&qStart, fOldDir, 0, 0);
D3DXQuaternionRotationYawPitchRoll(&qEnd, fNewDir, 0, 0);
D3DXQuaternionSlerp(&qFinal, &qStart, &qEnd, l_transform->m_MotionInfo.fS);
D3DXVECTOR3 finalDir;
D3DXVECTOR3 baseDir(1, 0, 0);
D3DXMATRIX matDir;
D3DXMatrixRotationQuaternion(&matDir, &qFinal);
D3DXVec3TransformCoord(&finalDir, &baseDir, &matDir);
l_transform->setRotation(D3DXVECTOR3(finalDir.x, 0, 0));
l_transform->setPosition(currPoss);
TRACE("t:" << l_transform->m_MotionInfo.fS);
TRACE("Desired Orientation: " << fNewDir);
TRACE("Instant. Orientation: " << finalDir.x);
TRACE("=====\n")


So the initial direction is at 0

So the interpolator is chasing 0.0862636

at time 1 it is at 0.99

therefore

0 => 0.08

and at 1, it is at

(0.99, 0, 0)

Perhaps it is turning a larger circle?

t:0.00607012
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 1
=====

t:0.0128147
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999999
=====

t:0.0202337
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999998
=====

t:0.0276528
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999997
=====

t:0.0350718
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999995
=====

t:0.0424909
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999993
=====

t:0.0499099
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999991
=====

t:0.0566545
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999988
=====

t:0.0640735
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999985
=====

t:0.0714925
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999981
=====

t:0.0782371
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999977
=====

t:0.0856562
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999973
=====

t:0.0930752
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999968
=====

t:0.0998198
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999963
=====

t:0.107239
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999957
=====

t:0.113983
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999952
=====

t:0.121402
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999945
=====

t:0.128821
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999938
=====

t:0.135566
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999932
=====

t:0.142985
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999924
=====

t:0.14973
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999917
=====

t:0.157149
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999908
=====

t:0.164568
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999899
=====

t:0.171987
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99989
=====

t:0.179406
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99988
=====

t:0.18615
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999871
=====

t:0.192895
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999861
=====

t:0.19964
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999852
=====

t:0.207059
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99984
=====

t:0.214478
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999829
=====

t:0.221222
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999818
=====

t:0.228641
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999805
=====

t:0.235386
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999794
=====

t:0.242805
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999781
=====

t:0.249549
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999768
=====

t:0.256968
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999754
=====

t:0.263713
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999741
=====

t:0.271132
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999726
=====

t:0.277877
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999713
=====

t:0.285296
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999697
=====

t:0.292715
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999681
=====

t:0.299459
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999666
=====

t:0.306878
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99965
=====

t:0.314297
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999632
=====

t:0.321042
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999617
=====

t:0.328461
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999599
=====

t:0.335206
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999582
=====

t:0.342625
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999563
=====

t:0.349369
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999546
=====

t:0.356788
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999526
=====

t:0.364207
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999506
=====

t:0.370952
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999488
=====

t:0.378371
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999467
=====

t:0.385116
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999448
=====

t:0.392535
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999427
=====

t:0.399279
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999407
=====

t:0.406024
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999387
=====

t:0.413443
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999364
=====

t:0.420862
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999341
=====

t:0.427607
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99932
=====

t:0.435026
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999296
=====

t:0.44177
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999274
=====

t:0.449189
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999249
=====

t:0.455934
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999227
=====

t:0.463353
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999201
=====

t:0.470098
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999178
=====

t:0.477517
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999152
=====

t:0.484261
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999128
=====

t:0.49168
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999101
=====

t:0.499099
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999073
=====

t:0.505844
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.999048
=====

t:0.513263
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99902
=====

t:0.520682
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998991
=====

t:0.528101
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998962
=====

t:0.53552
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998933
=====

t:0.542939
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998903
=====

t:0.549684
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998876
=====

t:0.557103
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998845
=====

t:0.563847
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998817
=====

t:0.570592
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998789
=====

t:0.578011
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998757
=====

t:0.58543
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998725
=====

t:0.592175
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998695
=====

t:0.599594
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998663
=====

t:0.606338
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998632
=====

t:0.613083
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998602
=====

t:0.620502
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998568
=====

t:0.627246
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998536
=====

t:0.634665
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998502
=====

t:0.64141
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99847
=====

t:0.648154
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998437
=====

t:0.655574
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998401
=====

t:0.662318
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998368
=====

t:0.669063
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998335
=====

t:0.677831
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998291
=====

t:0.684575
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998257
=====

t:0.69132
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998222
=====

t:0.698739
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998184
=====

t:0.705483
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998149
=====

t:0.712902
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99811
=====

t:0.719647
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998074
=====

t:0.727066
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.998034
=====

t:0.734485
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997993
=====

t:0.74123
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997956
=====

t:0.748649
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997915
=====

t:0.756068
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997874
=====

t:0.763487
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997832
=====

t:0.770906
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99779
=====

t:0.778325
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997747
=====

t:0.785069
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997708
=====

t:0.792489
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997664
=====

t:0.799233
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997624
=====

t:0.806652
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99758
=====

t:0.813397
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997539
=====

t:0.820141
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997498
=====

t:0.828235
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997449
=====

t:0.834979
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997407
=====

t:0.841724
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997365
=====

t:0.849143
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997318
=====

t:0.855887
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997276
=====

t:0.863307
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997228
=====

t:0.870051
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997185
=====

t:0.87747
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997137
=====

t:0.884215
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997092
=====

t:0.890959
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.997048
=====

t:0.898378
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996999
=====

t:0.905123
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996953
=====

t:0.912542
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996903
=====

t:0.919961
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996853
=====

t:0.926706
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996806
=====

t:0.934125
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996755
=====

t:0.940869
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996708
=====

t:0.948288
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996656
=====

t:0.955033
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996608
=====

t:0.962452
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996555
=====

t:0.969871
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996502
=====

t:0.97729
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996448
=====

t:0.984709
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996394
=====

t:0.991454
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996345
=====

t:0.998873
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.99629
=====

t:1
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.996282
=====

Edited by lucky6969b

##### Share on other sites

D3DXVECTOR3 finalDir;
D3DXVECTOR3 vStart(fOldDir, 0, 0);
D3DXVECTOR3 vEnd(fNewDir, 0, 0);
D3DXVec3Lerp(&finalDir, &vStart, &vEnd, l_transform->m_MotionInfo.fS);


The works better, but how come the direction suddenly changed polarity?

t:1
Start Orientation: 0
Desired Orientation: 0.0862636
Instant. Orientation: 0.0862636 << last direction
=====

t:0.00266075
Start Orientation: -0.0861567 << start up another frame with this (why became negative?)
Desired Orientation: 0.970148
Instant. Orientation: -0.0833461
=====


1. 1
Rutin
30
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632961
• Total Posts
3009494
• ### Who's Online (See full list)

There are no registered users currently online

×