Example #1
0
        public override void GenerateNewFrame(float dt)
        {
            //AnimationFrame output = new AnimationFrame();
            Reduce(.65f);
            Random random = new Random();

            double xFactor = Dome.LEDS_PER_RIB / Math.Sqrt(2.0f);
            double yFactor = Dome.LEDS_PER_RIB / Math.Sqrt(2.0f);

            if (m_XIncreasing)
            {
                m_X += 1.0f * m_UpdatePeriod;
                if (m_X >= m_XMax)
                {
                    m_X           = m_XMax;
                    m_XIncreasing = false;
                }
            }
            else
            {
                m_X -= 1.0f * m_UpdatePeriod;
                if (m_X <= -m_XMax)
                {
                    m_X           = -m_XMax;
                    m_XIncreasing = true;
                }
            }

            double wX = m_X;
            double wY = m_X + 4.0f;

            // change this to change the parameterization of the inner circle
            int    thetaSteps     = 360;      // 36
            double radiansPerStep = (double)(2.0f * Math.PI / thetaSteps);

            // not sure if we want to really modulate this at all
            double c = dt;

            for (int i = 0; i < thetaSteps; i++)
            {
                double theta     = (double)i * radiansPerStep;
                double x         = xFactor * Math.Sin((wX * theta) + c);
                double y         = yFactor * Math.Sin(wY * theta);
                double r         = Math.Sqrt(Math.Pow(x, 2.0f) + Math.Pow(y, 2.0f));
                double drawTheta = Math.Atan2(y, x);

                // ATan2 returns values from of -π≤θ≤π
                drawTheta += Math.PI;
                int rib = Dome.GetNearestRibByRadians(drawTheta);

                Color newColor = ColorManager.RandomColor();
                m_CurrentFrame.SetLedColor(rib, (int)r, newColor);
            }

            //m_CurrentFrame = output;
        }
Example #2
0
        public override void GenerateNewFrame(float dt)
        {
            Reduce(.85f);
            //AnimationFrame output = new AnimationFrame();
            Random random = new Random();

            m_currentSinParameter += (m_UpdatePeriod * m_sinWaveIncrement);

            //double a = (float)Dome.LEDS_PER_RIB;
            double currentSin = Math.Sin(m_currentSinParameter);

            currentSin += 1.0f;
            currentSin *= 1.5f;

            int totalNodes = (int)(currentSin * (float)(m_maxNodes - m_minNodes));             // number of nodes along the structure

            totalNodes += m_minNodes;
            double w = Dome.LEDS_PER_RIB;                        // radius of circle to fill (movie is 300 pixels wide)

            double phi = (Math.Sqrt(5.0f) + 1.0f) / 2.0f - 1.0f; // the golden ratio
            double ga  = phi * 2.0f * Math.PI;                   // the golden angle - used for phyllotaxis on many plants

            for (int i = 1; i <= totalNodes; i++)
            {
                double theta = i * ga;                                            // angle of phyllotaxis
                double r     = Math.Log(1.0f + i * (Math.E - 1.0f) / totalNodes); // logarithmic distance to edge of movie (0-1)

                r *= w;
                r--;
                // make sure that this theta get bounded from [0,2π]
                int radians = (int)(theta / (1.0f * Math.PI));
                theta = theta - ((double)radians * (1.0f * Math.PI));

                int rib = Dome.GetNearestRibByRadians(theta);
                m_CurrentFrame.SetLedColor(rib, (int)r, m_Color);

                // for some reason, this was only filling in from 0 to PI
                // so, i guess we'll draw the other side?  i dunno... :)
                theta += Math.PI;

                rib = Dome.GetNearestRibByRadians(theta);
                m_CurrentFrame.SetLedColor(rib, (int)r, m_Color);
            }


            //m_CurrentFrame = output;
        }
Example #3
0
        public override void  GenerateNewFrame(float dt)
        {
            Reduce(.9f);
            //AnimationFrame output = new AnimationFrame();
            m_currentSinParameter += m_sinWaveIncrement;

            // change this to change the parameterization of the function
            int    thetaSteps     = 360; // 36
            double radiansPerStep = (double)(2.0f * Math.PI / thetaSteps);
            double a           = (float)Dome.LEDS_PER_RIB;
            double thetaNaught = 0.0f;
            double currentSin  = Math.Sin(m_currentSinParameter);

            currentSin += 1.0f;
            currentSin *= 0.5f;

            double k = currentSin * m_kMax;

            for (int i = 0; i < thetaSteps; i++)
            {
                double theta  = (double)i * radiansPerStep;
                double radius = (a * Math.Cos((k * theta) + thetaNaught)) - 1;

                if (radius > 49.0)
                {
                    radius = 49.0;
                }
                else if (radius < 0.0)
                {
                    radius = 0.0;
                }

                int rib = Dome.GetNearestRibByRadians(theta);
                m_CurrentFrame.SetLedColor(rib, (int)radius, ColorManager.RandomColor());
            }

            //m_CurrentFrame = output;
        }
Example #4
0
        public override void GenerateNewFrame(float dt)
        {
            //AnimationFrame output = new AnimationFrame();
            Reduce(.75f);
            Random random = new Random();

            m_currentSinParameter += m_sinWaveIncrement;

            double a          = (float)Dome.LEDS_PER_RIB;
            double currentSin = Math.Sin(m_currentSinParameter);

            currentSin += 1.0f;
            currentSin *= 0.5f;
            double b = (a * currentSin);

            // change this to change the parameterization of the inner circle
            int    thetaSteps     = 360;      // 36
            double radiansPerStep = (double)(2.0f * Math.PI / thetaSteps);

            for (int i = 0; i < thetaSteps; i++)
            {
                double theta     = (double)i * radiansPerStep;
                double x         = ((a - b) * Math.Cos(theta)) + (b * Math.Cos((theta * (a - b)) / b));
                double y         = ((a - b) * Math.Sin(theta)) - (b * Math.Sin((theta * (a - b)) / b));
                double r         = Math.Sqrt(Math.Pow(x, 2.0f) + Math.Pow(y, 2.0f)) - 1;
                double drawTheta = Math.Atan2(y, x);

                // ATan2 returns values from of -π≤θ≤π
                drawTheta += Math.PI;
                int rib = Dome.GetNearestRibByRadians(drawTheta);

                Color newColor = ColorManager.RandomColor();
                m_CurrentFrame.SetLedColor(rib, (int)r, newColor);
            }

            //m_CurrentFrame = output;
        }