PDA

View Full Version : A helical path



garbash
11-02-2000, 07:19 PM
Can someone help me out? I have to make an object move along a helical path, prefereably around the Y axis. Can someone give me the code fragment that will let me do this in terms of glTranslated(x,y,z) ?
Be very much appreciated.

smart_idiot
11-03-2000, 10:22 AM
(updated)

I'm not sure what you mean, but if you are discribing a spring-like path (use smaller words, I'm stupid), try this:

glTranslated(sin(var*spinspeed)*size+x_offset,cos( var/spinspeed)*size+y_offset,var*rise_speed+z_offset);

var: % of path
spinspeed: speed of revolution (negetive values for the other direction)
size: radius of path(negetive reverses turn direction)
rise_speed: speed it rises (negetive values make things fall down.)
x_offset,y_offset,z_offset: offset to position

you need math.h I think and you will probably want to use a sine and cosine table. Remove what you don't need, and you will likely need to swap the axises. (I use x,y,z, but opengl uses x,z,y I think.)

I hope that is helpful, but I doubt it. Good luck. This is as much as I can do with grade 10 math.

--Smart_idiot

PS

I want to know it I actually helped anybody so let me know it this it helped you.

I'm canadian, eh?


[This message has been edited by smart_idiot (edited 11-03-2000).]

yoda
11-03-2000, 10:46 AM
The equation for plotting a helix is (cos(t), sin(t), bt) where t is some changing value (ie. a for loop variable) and b is some constant for the "height" displacement of the helix. http://www.opengl.org/discussion_boards/ubb/cool.gif

smart_idiot
11-03-2000, 11:14 AM
Sorry, I was close.

I think that mine will just be rotated by 90 degrees.

I won't hinder anyone else with false information again. (until monday)

I was just trying to help.