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

## 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?

Thanks

Jack

##### Share on other sites

Subtract R from y maybe? What exactly is supposed to happen?

##### 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!

Jack

Edited by lucky6969b

##### 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?

Thanks

Jack

Edited by lucky6969b

##### 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 on other sites

Hello,

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

Thanks

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)

D3DXVECTOR3 dot(D3DXVECTOR3 t1, D3DXMATRIX t2)
{

// 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)
{
D3DXMATRIX rZ;
D3DXMatrixIdentity(&rZ);
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

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633676
• Total Posts
3013279
×