Click here to Skip to main content
15,894,630 members
Articles / Programming Languages / C#

Universal Framework for Science and Engineering - Part 6: Determination of Orbits of Artificial Satellites

Rate me:
Please Sign up or sign in to vote.
4.88/5 (28 votes)
8 Jul 2011CPOL19 min read 82.5K   6.6K   82  
An article on framework applications to determine the orbits of artificial satellites
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Chart.Drawing.TextPainters
{
    public class LogarithmTextPainter : SimpleCoordTextPainter
    {

        #region Overriden Members

        public override void DrawTextX(Graphics g, int[,] insets, double[,] dSize, int[] size, double[] scale)
        {
            drawTextXLog(g, insets, dSize, size, scale);
        }

        public override void DrawTextY(Graphics g, int[,] insets, double[,] dSize, int[] size, double[] scale)
        {
            drawTextXLog(g, insets, dSize, size, scale);
        }

        #endregion


        #region Members


        protected void drawTextXLog(Graphics g, int[,] insets, double[,] dSize, int[] size, double[] scale)
        {
            Font font = new Font("Times", 13);
            Font fontPow = new Font("Times", 6);
            Brush brush = new SolidBrush(Color.Black);
            int h = font.Height + insets[0, 1] + size[1];
            Pen pen = new Pen(Color.Black);
            int min = (int)Math.Floor(dSize[0, 0]);
            int max = (int)Math.Ceiling(dSize[1, 0]);
            for (int j = min; j <= max; j++)
            {
                //string ss = "";
                /*for (int k = 0; k < j; k++)
                {
                    ss = ss + "0";
                }
                string sp = "";
                for (int k = 0; k > j + 1; k--)
                {
                    sp = sp + "0";
                }
                if (j < 0)
                {
                    sp = "0," + sp;
                }*/
                string sp = "1";
                if (j > 0)
                {
                    sp += "e+" + j;
                }
                if (j < 0)
                {
                    sp += "e" + j;
                }
                for (int k = 0; k < 10; k++)
                {
                    double c = j + Math.Log10(k);
                    if ((c < dSize[0, 0]) | (c > dSize[1, 0]))
                    {
                        continue;
                    }
                    performer.Transform(c, 0.0, p);
                    string s = k + "";
                    int w = (int)g.MeasureString(sp, font).Width;
                    int x = p[0] + insets[0, 0] - w / 2;
                    if (k == 1)
                    {
                        string sh = sp;// +k + ss;
                        g.DrawString(sh, font, brush, x, h);
                    }
                    /*if ((k == 0) & (j != 0))
					{
                        g.DrawString(sp + k + ss, fontPow, brush, x + w, h - font.Height + fontPow.Height);
                    }*/
                }
            }
        }

        protected void drawTextYLog(Graphics g, int[,] insets, double[,] dSize, int[] size, double[] scale)
        {
            Font font = new Font("Times", 13);
            Font fontPow = new Font("Times", 6);
            Brush brush = new SolidBrush(Color.Black);
            int h = font.Height + insets[0, 1] + size[1];
            Pen pen = new Pen(Color.Black);
            int min = (int)Math.Floor(dSize[0, 1]);
            int max = (int)Math.Ceiling(dSize[1, 1]);
            for (int j = min; j <= max; j++)
            {
                string ss = "";
                /*    for (int k = 0; k < j; k++)
                    {
                        ss = ss + "0";
                    }
                    string sp = "";
                    for (int k = 0; k > j; k--)
                    {
                        sp = sp + "0";
                    }
                    if (sp.Length > 0)
                    {
                        sp = "0," + sp;
                    }*/
                string sp = "1";
                if (j > 0)
                {
                    sp += "e+" + j;
                }
                if (j < 0)
                {
                    sp += "e" + j;
                }
                for (int k = 0; k < 10; k++)
                {
                    double c = j + Math.Log10(k);
                    if ((c < dSize[0, 1]) | (c > dSize[1, 1]))
                    {
                        continue;
                    }
                    performer.Transform(0.0, c, p);
                    string s = k + "";
                    int w = (int)g.MeasureString("13", font).Width;
                    int y = p[1] + insets[0, 1];
                    if (k == 1)
                    {
                        string sh = sp;// +k + ss;
                        w = (int)g.MeasureString(sh, font).Width;
                        g.DrawString(sh, font, brush, insets[0, 0] - (int)(double)(1.2 * w), y);
                    }
                    if ((k == 0) & (j != 0))
                    {
                        w = (int)g.MeasureString("7", font).Width;
                        g.DrawString(sp + k + ss, fontPow, brush, insets[0, 0] - (int)(double)(1.2 * w), y - font.Height + fontPow.Height);
                    }
                }
            }
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions