Jump to content
  • Advertisement
Sign in to follow this  

Finding the instantaneous position on a helix

This topic is 803 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

x = startBase.x + path->R * sin(t);
y = startBase.y + path->R * cos(t);
z = startBase.z + path->R * t;       


Let's say I'm counting off from 0, 0, 0

and the turning radius is 1000 meters.

at time 0.0, cos(t) is at R, which wasn't quite right.

Because at time 0.0, the agent should be close to 0.

What should be corrected?



Share this post

Link to post
Share on other sites

Thanks kolrabi,

I've just sort of figured out what should be the correct way.

I should be looking into the center of the rotation instead?

But really Thanks, appreciated!


Edited by lucky6969b

Share this post

Link to post
Share on other sites

Back to it,

So I am needing to use the Polar coordinate system to find the instantaneous position.

I already had the R and the theta, is it just simply do

x = R * sin(t)

y = R * cos(t)


without respect to z (up)


And the final product should be

x = center_of_rotation.x + R * cos(t)

y = center_of_rotation.y + R * sin(t)


depending on whether I am passing the quadrant marks?




Edited by lucky6969b

Share this post

Link to post
Share on other sites

You aim to move around on a circle in the xy plane, while going up in z? I think all your fomulas do that.

The only difference is the initial starting point in the xy plane.


You can somewhat tweak that by swapping cos and sin around (cos and sin are basically the same function, they are just shifted by 90 degrees (or pi/2 if you use radians).


A more flexible approach is to add a little extra rotation, like at time 0, you already move to the right start angle in the xy plane.

x = center_of_rotation.x + R * cos(t + start_angle)

y = center_of_rotation.y + R * sin(t + start_angle)

Share this post

Link to post
Share on other sites


I finally got some credible results.

But Only one thing

When the agent travels from say radian of 0

and when it elevates to a directional vector of which it has a -ve x component (I meant just going left)

The right solution comes up to my mind was the agent turns right and starts to elevate and goes around

eventually hitting a sort of upwards vector which pointing to the left and going into the screen somewhat.


But With Slerp or Lerp which comes from D3DX, the interpolation always wants to choose the shortest path,

I want the interpolation function takes the longer path, which indeed has to go around a large helix

before hitting the straight line segment, In my case, it chooses a shorter path and then connects with

the straight line with an abrupt turn which I believe is wrong.


When the dubins got some ideas knowing it is a right turn, can I force the Slerp or Lerp to go around

and choose the longer path?


Or In the picture, the agent actually has to go the other way round, but it *must* choose a longer path before

it stops the interpolation.


Hang on, I double checked, looks like the directional vector is wrong, the right turn ends at 0.6,xx,xx What the heck

So the interpolation will stop very quickly



Jack[attachment=33558:2016-09-30 16_31_13-TestSB.jpg]



But wait a minute


Why with a right turn, the center of rotation should be in the positive x range

What did I do wrong?


[attachment=33559:2016-09-30 16_59_18-TestOpenTissue2 (Debugging) - Microsoft Visual Studio (Administrator).jpg]


Oh hell yeah.... rotZ(PI/2) instead of rotZ(-PI/2)


    // x = ax + by + cz
    // y = px + qy + rz
    // z = ux + vy + wz

    //double x = t1.x * t2._11 + t1.y * t2._21 + t1.z * t2._31;
    //double y = t1.x * t2._12 + t1.y * t2._22 + t1.z * t2._32;
    //double z = t1.x * t2._13 + t1.y * t2._23 + t1.z * t2._33;

    double x = t1.x * t2._11 + t1.y * t2._12 + t1.z * t2._13;
    double y = t1.x * t2._21 + t1.y * t2._22 + t1.z * t2._23;
    double z = t1.x * t2._31 + t1.y * t2._32 + t1.z * t2._33;
    return D3DXVECTOR3(x, y, z);
D3DXMATRIX rotZ(float angle)
    D3DXMatrixRotationZ(&rZ, angle);
    return rZ;

Okay, I know now, I messed up the code before, I just did too much to the code[attachment=33560:2016-09-30 17_31_22-TestSB.jpg]

Edited by lucky6969b

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!