Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // spring geometry
- // by @_sorceress
- C = 8.00; // number of coils in the spring
- L = 8.00; // length of the spring (this is what you want to vary)
- R = 1.00; // radius of the spring
- G = 0.15; // gauge of spring wire
- ures = 10*C; // steps along spring wire
- vres = 10; // steps around spring wire
- for(v=0; v<vres; v++) {
- vscale = 2*PI*v/vres;
- gr = G * cos(vscale) + R;
- gz = G * sin(vscale);
- for(u=0; u<ures; u++) {
- uscale = u/ures;
- x = gr * cos(2*PI*C*uscale);
- y = gr * sin(2*PI*C*uscale);
- z = gz + L * uscale;
- // Output vector (x,y,z) which you can use in a vertex array, or whatever
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement