Example #1
0
        //public void PlotLinear(int x, float amplitude, int k, int i, EllipseGeometry firstEllipseGeometry, int c)
        //{
        //    // The point (0,0) for the amplitude y and the pixelrow x is the bottom left corner.
        //    // The point (0,0) for the C# methods is the top left corner.
        //    double y;
        //    // stetige plots
        //    //y = (double)((amplitude - this.offset + 0.00001) * this.scale);
        //    y = (double)((amplitude - this.offset) * this.scale);

        //    EllipseGeometry secondEllipseGeometry = firstEllipseGeometry.Clone();
        //    LineGeometry myLineGeometry = new LineGeometry();
        //    GeometryGroup gg = new GeometryGroup();
        //    //Point startPoint = new Point();
        //    //Point endPoint = new Point();
        //    double a = Math.Abs(x - this.xTemp);
        //    double b = Math.Abs(y - this.yTemp[c]);

        //    if ((this.yTemp[c] > this.ImageWidth && y > this.ImageWidth) || (this.yTemp[c] < 0 && y < 0) || (this.xTemp < 0 && x < 0) || (this.xTemp > this.ImageHeight && x > this.ImageHeight))
        //    {
        //        // Both points are out of the visible bitmap: Draw nothing
        //    }
        //    else if ((this.yTemp[c] >= 0 && y >= 0) && (this.yTemp[c] <= this.ImageWidth && y <= this.ImageWidth) && (this.xTemp >= 0 && x >= 0) && (this.xTemp <= this.ImageHeight && x <= this.ImageHeight))
        //    {
        //        // Both points are inside the visible bitmap: Draw line
        //        myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //        myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //        // paint the line, if there is mind. 2 Points
        //        firstEllipseGeometry.Center = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //        gg.Children.Add(firstEllipseGeometry);
        //        secondEllipseGeometry.Center = new Point(x, this.ImageWidth - y);
        //        gg.Children.Add(secondEllipseGeometry);
        //        // Draw line, if it exits min. two Points
        //    }
        //    else if (this.xTemp < 0 && x > this.ImageHeight)
        //    {
        //        if (yTemp[c] <= y)
        //        {
        //            myLineGeometry.StartPoint = new Point(0, this.ImageWidth - (Math.Abs(this.xTemp) * b / a) - this.yTemp[c]);
        //            myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((this.ImageHeight - this.xTemp) * b / a) - this.yTemp[c]);
        //        }
        //        else
        //        {
        //            myLineGeometry.StartPoint = new Point(0, this.ImageWidth - (x * b / a) - y);
        //            myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((x - this.ImageHeight) * b / a) - y);
        //        }
        //    }
        //    else
        //    {
        //        // endpoint within ImageWith
        //        if (y >= 0 && y <= this.ImageWidth)
        //        {
        //            // startpoint ist unten links von Bitmap
        //            if (this.xTemp < 0 && this.yTemp[c] < 0)
        //            {
        //                // Zwischenspunkt liegt auf den horizontal Achse
        //                if ((Math.Abs((double)y / this.yTemp[c])) < (Math.Abs((double)x / this.xTemp)))
        //                {
        //                    myLineGeometry.StartPoint = new Point(x - (a * y / b), this.ImageWidth);
        //                }
        //                // Zwischenspunkt liegt auf den vertikale Achse
        //                if ((Math.Abs((double)y / this.yTemp[c])) > (Math.Abs((double)x / this.xTemp)))
        //                {
        //                    myLineGeometry.StartPoint = new Point(0, this.ImageWidth - y + (b * x / a));
        //                }
        //                myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                gg.Children.Add(secondEllipseGeometry);
        //            }
        //            // startpoint ist oben links von Bitmap
        //            else if (this.xTemp < 0 && this.yTemp[c] >= this.ImageWidth)
        //            {
        //                // Zwischenspunkt liegt auf den horizontal Achse(obere Achse)
        //                if ((Math.Abs((double)(this.ImageWidth - y) / (this.ImageWidth - this.yTemp[c]))) < (Math.Abs((double)x / this.xTemp)))
        //                {
        //                    myLineGeometry.StartPoint = new Point((a * (this.yTemp[c] - this.ImageWidth) / b - Math.Abs(this.xTemp)), 0);
        //                }
        //                // Zwischenspunkt liegt auf den vertikale Achse
        //                if ((Math.Abs((double)(this.ImageWidth - y) / (this.ImageWidth - this.yTemp[c]))) > (Math.Abs((double)x / this.xTemp)) || (this.yTemp[c] == this.ImageWidth))
        //                {
        //                    myLineGeometry.StartPoint = new Point(0, b * Math.Abs(this.xTemp) / a - this.yTemp[c] + this.ImageWidth);
        //                }
        //                myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                gg.Children.Add(secondEllipseGeometry);
        //            }
        //            else
        //            {
        //                // Startpoint ist unten von Bitmap
        //                if (this.yTemp[c] < 0)
        //                {
        //                    // endpoint innerhalb von visualen Bitmap
        //                    if (x > 0 && x < this.ImageHeight)
        //                    {
        //                        myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                        secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                        gg.Children.Add(secondEllipseGeometry);
        //                    }
        //                    // endpoint ist rechts von visualen Bitmap
        //                    else if (x > this.ImageWidth)
        //                    {
        //                        myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((this.ImageHeight - this.xTemp) * b / a) - this.yTemp[c]);
        //                    }
        //                    if (this.xTemp >= 0)
        //                    {
        //                        myLineGeometry.StartPoint = new Point(this.xTemp + (Math.Abs(this.yTemp[c]) * a / b), this.ImageWidth);
        //                    }
        //                    if (this.xTemp < 0)
        //                    {
        //                        myLineGeometry.StartPoint = new Point((Math.Abs(this.yTemp[c]) * a / b) - Math.Abs(this.xTemp), this.ImageWidth);
        //                    }
        //                }
        //                // Starting point is above of Bitmap/*
        //                else if (this.yTemp[c] > this.ImageWidth)
        //                {
        //                    if (x >= 0 && x <= this.ImageHeight)
        //                    {
        //                        myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                        secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                        gg.Children.Add(secondEllipseGeometry);
        //                    }
        //                    else if (x > this.ImageWidth)
        //                    {
        //                        myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((x - this.ImageHeight) * b / a) - y);
        //                    }
        //                    myLineGeometry.StartPoint = new Point((this.xTemp + (this.yTemp[c] - this.ImageWidth) * a / b), 0);
        //                }
        //                // Starting point is on the left side of Bitmap
        //                else
        //                {
        //                    if (this.xTemp < 0 && yTemp[c] <= y)
        //                    {
        //                        myLineGeometry.StartPoint = new Point(0, this.ImageWidth - (Math.Abs(this.xTemp) * b / a) - this.yTemp[c]);
        //                        myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                        secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                        gg.Children.Add(secondEllipseGeometry);
        //                    }
        //                    if (this.xTemp < 0 && yTemp[c] > y)
        //                    {
        //                        myLineGeometry.StartPoint = new Point(0, this.ImageWidth - (x * b / a) - y);
        //                        myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                        secondEllipseGeometry.Center = myLineGeometry.EndPoint;
        //                        gg.Children.Add(secondEllipseGeometry);
        //                    }
        //                    // the last point is on the right side of Image
        //                    if (x >= this.ImageHeight)
        //                    {
        //                        myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                        if (this.yTemp[c] == y)
        //                        {
        //                            myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - y);
        //                        }
        //                        if (this.yTemp[c] < y && this.yTemp[c] >= 0)
        //                        {
        //                            myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((this.ImageHeight - this.xTemp) * b / a) - this.yTemp[c]);
        //                        }
        //                        if (this.yTemp[c] > y)
        //                        {
        //                            myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - ((x - this.ImageHeight) * b / a) - y);
        //                        }
        //                    }
        //                }
        //            }
        //            // paint the line, if there is mind. 2 Points
        //        }
        //        // endpoint outside of the ImageWidth
        //        if (y < 0 || y > this.ImageWidth)
        //        {
        //            // endpoint ist oben rechts von visualen Bitmap
        //            if (x > this.ImageHeight && y > this.ImageWidth)
        //            {
        //                // Letzte Punkt liegt auf den vertikale Achse
        //                if ((Math.Abs((double)(this.ImageWidth - y) / (this.ImageWidth - this.yTemp[c]))) < (Math.Abs((double)(x - this.ImageHeight) / (this.ImageHeight - this.xTemp))))
        //                {
        //                    myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - this.yTemp[c] - (this.ImageHeight - this.xTemp) * b / a);
        //                }
        //                // Letzte Punkt liegt auf den horizontale Achse (obere Achse)
        //                if ((Math.Abs((double)(this.ImageWidth - y) / (this.ImageWidth - this.yTemp[c]))) > (Math.Abs((double)(x - this.ImageHeight) / (this.ImageHeight - this.xTemp))))
        //                {
        //                    myLineGeometry.EndPoint = new Point(this.xTemp + a * (this.ImageWidth - this.yTemp[c]) / b, 0);
        //                }
        //                myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //            }
        //            // endpoint ist unten rechts von visualen Bitmap
        //            else if (x > this.ImageHeight && y < 0)
        //            {
        //                // Letzte Punkt liegt auf den horizontale Achse(untere Achse)
        //                if ((Math.Abs((double)(y / this.yTemp[c]))) > (Math.Abs((double)(x / this.xTemp))))
        //                {
        //                    myLineGeometry.EndPoint = new Point(this.xTemp + a * this.yTemp[c] / b, this.ImageWidth);
        //                }
        //                // Letzte Punkt liegt auf den vertikale Achse
        //                if ((Math.Abs((double)(y / this.yTemp[c]))) < (Math.Abs((double)(x / this.xTemp))))
        //                {
        //                    myLineGeometry.EndPoint = new Point(this.ImageHeight, this.ImageWidth - this.yTemp[c] + b * (this.ImageHeight - this.xTemp) / a);
        //                }
        //                myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //            }
        //            // endpoint ist entweder oben oder unten von Bitmap
        //            else
        //            {
        //                // steigende Linie
        //                if (this.yTemp[c] < y)
        //                {
        //                    // endpoint ist oben, startpoint links
        //                    if (this.xTemp < 0 && this.yTemp[c] < this.ImageWidth)
        //                    {
        //                        myLineGeometry.StartPoint = new Point(0, this.ImageWidth - Math.Abs(xTemp) * b / a - this.yTemp[c]);
        //                        myLineGeometry.EndPoint = new Point(x - (y - this.ImageWidth) * a / b, 0);
        //                        myLineGeometry.StartPoint = myLineGeometry.StartPoint;
        //                        myLineGeometry.EndPoint = myLineGeometry.EndPoint;
        //                    }
        //                    // endpoint oben
        //                    else
        //                    {
        //                        // startpoint innerhalb von Bitmap
        //                        if (yTemp[c] >= 0 && yTemp[c] < this.ImageWidth)
        //                        {
        //                            myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                            myLineGeometry.EndPoint = new Point(this.xTemp + a * (this.ImageWidth - this.yTemp[c]) / b, 0);
        //                            firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //                            gg.Children.Add(firstEllipseGeometry);
        //                        }
        //                        // startpoint ist unten von Bitmap
        //                        else if (yTemp[c] < 0)
        //                        {
        //                            myLineGeometry.StartPoint = new Point(this.xTemp + a * Math.Abs(this.yTemp[c]) / b, this.ImageWidth);
        //                            myLineGeometry.EndPoint = new Point(this.xTemp + a * (this.ImageWidth - this.yTemp[c]) / b, 0);
        //                        }
        //                    }
        //                }
        //                // absteigende Linie
        //                else if (this.yTemp[c] > y)
        //                {
        //                    myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                    myLineGeometry.EndPoint = new Point(x, this.ImageWidth - y);
        //                    firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //                    gg.Children.Add(firstEllipseGeometry);
        //                    //// startpoint ist links von Bitmap
        //                    //if (this.xTemp < 0 && this.yTemp[c] > 0)
        //                    //{
        //                    //    myLineGeometry.StartPoint = new Point(0, this.ImageWidth - this.yTemp[c] + Math.Abs(xTemp) * b / a);
        //                    //    myLineGeometry.EndPoint = new Point(this.xTemp + a * (this.yTemp[c]) / b, this.ImageWidth);
        //                    //    firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //                    //    gg.Children.Add(firstEllipseGeometry);
        //                    //}
        //                    //else
        //                    //{
        //                    //    myLineGeometry.StartPoint = new Point(this.xTemp, this.ImageWidth - this.yTemp[c]);
        //                    //    myLineGeometry.EndPoint = new Point(this.xTemp + a * (this.yTemp[c]) / b, this.ImageWidth);
        //                    //    firstEllipseGeometry.Center = myLineGeometry.StartPoint;
        //                    //    gg.Children.Add(firstEllipseGeometry);
        //                    //}
        //                }
        //            }
        //        }
        //        // paint the line, if there is mind. 2 Points
        //    }
        //    if (k > 0)
        //    {
        //        gg.Children.Add(myLineGeometry);
        //    }
        //    this.geometrygroup.Children.Add(gg);
        //    this.xTemp = x;
        //    this.yTemp[c] = y;
        //}

        public void Peak(int pixelrow, SampleD sampledata)
        {
            int swap, xstart, xend;

            xstart = (int)((sampledata.max - offset) * scale);
            xend   = (int)((sampledata.min - offset) * scale);

            if (xstart > xend)
            {
                swap   = xend;
                xend   = xstart;
                xstart = swap;
            }

            // stetige plots
            if (this.xlastplot < xstart)
            {
                xstart = this.xlastplot;
            }

            if (this.xlastplot > xend)
            {
                xend = this.xlastplot;
            }

            this.xlastplot = (int)((sampledata.value - this.offset) * this.scale);

            this.ClippingAndPixeling(xstart, xend, pixelrow);
        }
Example #2
0
    static void Main(string[] args)
    {
        SampleD del1, del2, del3, del4; //Here we define the four delegates

        del1 = new SampleD(SampleD1);
        del2 = new SampleD(SampleD2);
        del3 = new SampleD(SampleD3);
        del4 = del1 + del2 + del3; //As you can see, del4 is the multicast delegate

        del4();                    //this function is run
    }
Example #3
0
        static void Main(string[] args)
    {
        SampleD del1, del2, del3, del4; //Here we define the four delegates
        del1 = new SampleD(SampleD1);
        del2 = new SampleD(SampleD2);
        del3 = new SampleD(SampleD3);
        del4 = del1 + del2 + del3; //As you can see, del4 is the multicast delegate

        del4(); //this function is run

    }
Example #4
0
		public void ComputeLine()
		{
			SampleD s = new SampleD();
			SampleD st = new SampleD();

			Sample minS = new Sample();
			Sample maxS = new Sample();

			//xMin = yMin = 1000000.0f;
			//xMax = yMax = -1000000.0f;

			if(Samples.Count > 0) {
				minS = Samples[0];
				maxS = Samples[0];
			}


			s.x = s.y = s.z = s.t = 0.0;
			st.t = st.x = st.y = st.z = 1.0;

			int n = Samples.Count;
			for( int i = 0; i < n; ++i )
			{
				s.t += Samples[i].t;
				s.x += Samples[i].x;
				s.y += Samples[i].y;
				s.z += Samples[i].z;

				if(Samples[i].t < minS.t) minS = Samples[i];
				if(Samples[i].t > maxS.t) maxS = Samples[i];

				/*
				xMin = Math.Min( xMin, Samples[i].t );
				xMax = Math.Max( xMax, Samples[i].t );
				yMin = Math.Min( yMin, Samples[i].x );
				yMax = Math.Max( yMax, Samples[i].x );
				yMin = Math.Min( yMin, Samples[i].y );
				yMax = Math.Max( yMax, Samples[i].y );
				yMin = Math.Min( yMin, Samples[i].z );
				yMax = Math.Max( yMax, Samples[i].z );
				//*/
			}

			for( int i = 0; i < n; ++i )
			{
				double t = Samples[i].t - s.t / n;
				st.t += t * t;
				st.x += t * Samples[i].x;
				st.y += t * Samples[i].y;
				st.z += t * Samples[i].z;
			}

			dSlope.x = st.x / st.t;
			dSlope.y = st.y / st.t;
			dSlope.z = st.z / st.t;

			dIntercept.x = (s.x - s.t * dSlope.x) / n;
			dIntercept.y = (s.y - s.t * dSlope.y) / n;
			dIntercept.z = (s.z - s.t * dSlope.z) / n;
		}
Example #5
0
        public void ComputeLine()
        {
            SampleD s  = new SampleD();
            SampleD st = new SampleD();

            Sample minS = new Sample();
            Sample maxS = new Sample();

            //xMin = yMin = 1000000.0f;
            //xMax = yMax = -1000000.0f;

            if (Samples.Count > 0)
            {
                minS = Samples[0];
                maxS = Samples[0];
            }


            s.x  = s.y = s.z = s.t = 0.0;
            st.t = st.x = st.y = st.z = 1.0;

            int n = Samples.Count;

            for (int i = 0; i < n; ++i)
            {
                s.t += Samples[i].t;
                s.x += Samples[i].x;
                s.y += Samples[i].y;
                s.z += Samples[i].z;

                if (Samples[i].t < minS.t)
                {
                    minS = Samples[i];
                }
                if (Samples[i].t > maxS.t)
                {
                    maxS = Samples[i];
                }

                /*
                 * xMin = Math.Min( xMin, Samples[i].t );
                 * xMax = Math.Max( xMax, Samples[i].t );
                 * yMin = Math.Min( yMin, Samples[i].x );
                 * yMax = Math.Max( yMax, Samples[i].x );
                 * yMin = Math.Min( yMin, Samples[i].y );
                 * yMax = Math.Max( yMax, Samples[i].y );
                 * yMin = Math.Min( yMin, Samples[i].z );
                 * yMax = Math.Max( yMax, Samples[i].z );
                 * //*/
            }

            for (int i = 0; i < n; ++i)
            {
                double t = Samples[i].t - s.t / n;
                st.t += t * t;
                st.x += t * Samples[i].x;
                st.y += t * Samples[i].y;
                st.z += t * Samples[i].z;
            }

            dSlope.x = st.x / st.t;
            dSlope.y = st.y / st.t;
            dSlope.z = st.z / st.t;

            dIntercept.x = (s.x - s.t * dSlope.x) / n;
            dIntercept.y = (s.y - s.t * dSlope.y) / n;
            dIntercept.z = (s.z - s.t * dSlope.z) / n;
        }