Crazy Spinner
eharetea

Using the cross product to manipulate particles.

Spinning particles with cross products in VEX.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Tuesday July 29th, 2008 09:04 PM


/*
*
* Author: Dan Lynch
*
*/

#pragma range switcher 0 2    
#pragma hint axis direction

#pragma choice switcher "0" "Add Velocity"
#pragma choice switcher "1" "Set Acceleration"
#pragma choice switcher "2" "Set Velocity"
#pragma hint sinswitch toggle
#pragma hint normalizeswitch toggle
#define DEGTORAD 3.14/360


pop
d_spin
        (
        vector axis = {0,1,0};
        string switcher="0";
        int sinswitch=0normalizeswitch=0;
        )
{
        // this when multiplied at the end gives each particle
        // their own speed instead of setting all particles to the same speed.
        float nspeed length(v);

        if (age==&& sinswitch) {
            sin(Frame*(15 DEGTORAD))*sin(Frame DEGTORAD)*(10);
        } 

        vector nP = -* {1,0,1};
        if ( P.== && P.== ) { 

        } else {
                if (switcher == "0") {
                    += cross(nPaxis);
                } else if (switcher == "1") {                
                    accel cross(nPaxis);
                } else {
                    cross(nPaxis);
                }
        }
        
        if (normalizeswitchnormalize(v)*nspeed;
        
}



Downloads:
Download: crazy_spinner.vfl 1 KB

Please login or Click Here to register for downloads
Creative Commons License
Crazy Spinner by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com