Exemple #1
0
    private System.Drawing.Color ArbitraryRedshiftBasedColor(CoordinateEngine.RelativisticObject dude, CoordinateEngine.RelativisticObject reference)
    {
        //Get z from the two objects
        //for information about z, see http://en.wikipedia.org/wiki/Redshift
        //z==0 means no shift
        //1+z = wavelength(observed)/wavelength(emitted)
        //so multiply the object's wavelength by (1+z)
        //the shift from pure green to pure red or pure blue to pure green is about z=0.17, so this would not be the most dynamic scale for large z
        double z = CoordinateEngine.calculateRedshiftZ(dude, universe.bro);

        //"Accurate" values
        const double upperlimit = 0.17;
        const double lowerlimit = -0.146;

        //Way to "soften" the quick and hard transition between colors.  The 1/exponent roughly multiplies the visible spectrum window...
        z = -1.0 + Math.Pow(1.0 + z, 1.0 / 1.0);

        if (z > upperlimit)//receding fast
        {
            return(System.Drawing.Color.FromArgb(127, 5, 10));
        }
        else if (z < lowerlimit)//approaching fast
        {
            return(System.Drawing.Color.FromArgb(127, 0, 255));
        }
        else if (z > 0.0)
        {
            return(System.Drawing.Color.FromArgb((int)(z / upperlimit * 255), (int)(255 * (1 - z / upperlimit)), 0));
        }
        else  //z<0.0
        {
            return(System.Drawing.Color.FromArgb(0, (int)(255 * (1 - z / lowerlimit)), (int)(z / lowerlimit * 255)));
        }
    }
Exemple #2
0
    //Populates the dudes, as a hard-coded demo
    public void InitDemo()
    {
        for (int i=0; i<DemoConsts.array_size_x; i++) {
            for (int j=0; j<DemoConsts.array_size_y; j++) {
                for (int k=0; k<DemoConsts.array_size_z; k++) {
                    //This mess of things at 0,0,0 sorts itself out after a few frames using UpdateDudes(), don't worry
                    CoordinateEngine.RelativisticObject new_guy = new CoordinateEngine.RelativisticObject(0,0,0);

                    new_guy.vrms = DemoConsts.speed;
                    double new_gamma = double.PositiveInfinity;
                    if(DemoConsts.speed<1.0){
                        new_gamma = CoordinateEngine.computeGamma(DemoConsts.speed);
                    }
                    new_guy.gamma = new_gamma;

                    dudes.Add(new_guy);
                }
            }
        }
    }
Exemple #3
0
    //Populates the dudes, as a hard-coded demo
    public void InitDemo()
    {
        for (int i = 0; i < DemoConsts.array_size_x; i++)
        {
            for (int j = 0; j < DemoConsts.array_size_y; j++)
            {
                for (int k = 0; k < DemoConsts.array_size_z; k++)
                {
                    //This mess of things at 0,0,0 sorts itself out after a few frames using UpdateDudes(), don't worry
                    CoordinateEngine.RelativisticObject new_guy = new CoordinateEngine.RelativisticObject(0, 0, 0);

                    new_guy.vrms = DemoConsts.speed;
                    double new_gamma = double.PositiveInfinity;
                    if (DemoConsts.speed < 1.0)
                    {
                        new_gamma = CoordinateEngine.computeGamma(DemoConsts.speed);
                    }
                    new_guy.gamma = new_gamma;

                    dudes.Add(new_guy);
                }
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// Draw a single RelativisticObject to the screen.
    /// </summary>
    /// <param name="ro">The RelativisticObject to draw.</param>
    /// <param name="issilver">Whether that object should be silver I guess</param>
    /// <remarks>
    /// What? You want to choose a color? Get off my lawn!
    /// </remarks>
    private void DrawRelativisticObject(CoordinateEngine.RelativisticObject ro, bool issilver = true)
    {
        double x;
        double y;
        double z;

        if (SHOULD_LORENTZ_TRANSFORM_IMAGE)
        {
            double[] apparent_position = CoordinateEngine.ApparentPosition(ro.x, universe.bro.x, universe.bro.v);
            x = apparent_position[_x];
            y = apparent_position[_y];
            z = apparent_position[_z];
        }
        else
        {
            x = ro.x[_x];
            y = ro.x[_y];
            z = ro.x[_z];
        }

        //double size = .01*Math.Sqrt (CoordinateEngine.RMS(universe.bro.x));
        double size = 0.042; //Diameter of the Earth if t=seconds

        size /= 2;           //Turns size into the side length of the cube

        GL.Begin(BeginMode.Quads);
        if (issilver)
        {
            GL.Color3(ArbitraryRedshiftBasedColor(ro, universe.bro));
        }
        else
        {
            GL.Color3(Color.Blue);
        }

        // front
        GL.Vertex3(x - size, y - size, z + size);
        GL.Vertex3(x - size, y + size, z + size);
        GL.Vertex3(x + size, y + size, z + size);
        GL.Vertex3(x + size, y - size, z + size);

        // right
        GL.Vertex3(x + size, y - size, z + size);
        GL.Vertex3(x + size, y + size, z + size);
        GL.Vertex3(x + size, y + size, z - size);
        GL.Vertex3(x + size, y - size, z - size);

        // bottom
        GL.Vertex3(x + size, y - size, z - size);
        GL.Vertex3(x + size, y - size, z + size);
        GL.Vertex3(x - size, y - size, z + size);
        GL.Vertex3(x - size, y - size, z - size);

        // left
        GL.Vertex3(x - size, y - size, z - size);
        GL.Vertex3(x - size, y - size, z + size);
        GL.Vertex3(x - size, y + size, z + size);
        GL.Vertex3(x - size, y + size, z - size);

        // top
        GL.Vertex3(x - size, y + size, z - size);
        GL.Vertex3(x - size, y + size, z + size);
        GL.Vertex3(x + size, y + size, z + size);
        GL.Vertex3(x + size, y + size, z - size);

        // back
        GL.Vertex3(x + size, y + size, z - size);
        GL.Vertex3(x + size, y - size, z - size);
        GL.Vertex3(x - size, y - size, z - size);
        GL.Vertex3(x - size, y + size, z - size);

        GL.End();
    }