Пример #1
0
 /// <summary>
 /// Creates StarTrackerByMax for static object(star) with default Tolerance.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 /// <param name="reference">
 /// Reference star in tracking, null means no reference.
 /// </param>
 public StarTrackerByMax(Vector2D position, IStarTracker reference)
 {
     _position = position;
     _tolerance = 10.0f;
     _reference = reference;
     _movable = false;
     if (_reference != null)
         _relPosition = _position - _reference.Position;
 }
Пример #2
0
 /// <summary>
 /// Draw cross on plot.
 /// </summary>
 /// <param name="graphics">
 /// Plot drawing surface.
 /// </param>
 /// <param name="data">
 /// Data point to transform and draw.
 /// </param>
 /// <param name="plotTransform">
 /// Transformation between data coordinates and image coordinates on plot.
 /// </param>
 public void DrawPoint(Graphics graphics, Vector2D data, PlotTransform plotTransform)
 {
     Point center = plotTransform(data);
     graphics.DrawLine(_pen, center.X - _size, center.Y, center.X + _size, center.Y);
     graphics.DrawLine(_pen, center.X, center.Y - _size, center.X, center.Y + _size);
 }
Пример #3
0
 public SelectionRequest()
 {
     waitEvent = new EventWaitHandle(false, EventResetMode.AutoReset);
     position = new Vector2D(0.0f, 0.0f);
 }
Пример #4
0
 /// <summary>
 /// Creates StarTrackerByMax with no Reference.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 /// <param name="tolerance">
 /// Tolerance in star tracking.
 /// </param>
 public StarTrackerByMax(Vector2D position, float tolerance)
 {
     _position = position;
     _tolerance = tolerance;
     _reference = null;
 }
Пример #5
0
        /// <summary>
        /// Track star method
        /// </summary>
        /// <remarks>
        /// Find selected star on image. Updates Position property, when Movable flag is set, and Reference is not null, 
        /// also updates RelPosition property.
        /// </remarks>
        /// <param name="image">
        /// An image to find selected star.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// Thrown when specified image is not 2D matrix.
        /// </exception>
        /// <exception cref="SARA.Astrometry.StarEscapedException">
        /// Thrown when field where star is looking for is completly out of image.
        /// </exception>
        public void Track(FloatMatrix image)
        {
            if (image.Dimensions.Length != 2)
                throw new ArgumentException("Expected 2D matrix");

            if (_reference != null)
                _position = _reference.Position + _relPosition;

            int minX = (int)(_position.X - _tolerance);
            int maxX = (int)(_position.X + _tolerance);
            int minY = (int)(_position.Y - _tolerance);
            int maxY = (int)(_position.Y + _tolerance);

            if (maxX < 0 || maxY < 0 || minX >= image.Dimensions[0] || minY >= image.Dimensions[1])
                throw new StarEscapedException("Star escaped");

            if (minX < 0) minX = 0;
            if (minY < 0) minY = 0;
            if (maxX >= image.Dimensions[0]) maxX = image.Dimensions[0] - 1;
            if (maxY >= image.Dimensions[1]) maxY = image.Dimensions[1] - 1;

            int pos0 = minY * image.Dimensions[0];
            _position = new Vector2D((float)minX, (float)minY);
            float best = image.Data[pos0 + minX];

            for (int y = minY; y <= maxY; y++)
            {
                for (int x = minX; x <= maxX; x++)
                {
                    if (best < image.Data[pos0 + x])
                    {
                        best = image.Data[pos0 + x];
                        _position = new Vector2D((float)x, (float)y);
                    }
                }
                pos0 += image.Dimensions[0];
            }

            if (_reference != null && _movable)
                _relPosition = _position - _reference.Position;
        }
Пример #6
0
 /// <summary>
 /// Creates StarTrackerByMax with no Reference and default Tolerance.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 public StarTrackerByMax(Vector2D position)
 {
     _position = position;
     _tolerance = 10.0f;
     _reference = null;
 }
Пример #7
0
 /// <summary>
 /// Creates StarTrackerByMax.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 /// <param name="tolerance">
 /// Tolerance in star tracking.
 /// </param>
 /// <param name="reference">
 /// Reference star in tracking, null means no reference.
 /// </param>
 /// <param name="movable">
 /// Flag sets for movable object (planetoids, minor planets) and clear for static objects (stars).
 /// </param>
 /// <param name="relPosition">
 /// Position relative to reference star.
 /// </param>
 public StarTrackerByMax(Vector2D position, float tolerance, IStarTracker reference, bool movable, Vector2D relPosition)
 {
     _position = position;
     _tolerance = tolerance;
     _reference = reference;
     _movable = movable;
     _relPosition = relPosition;
 }
Пример #8
0
 /// <summary>
 /// Creates StarTrackerByMax for static object(star) with default Tolerance.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 /// <param name="reference">
 /// Reference star in tracking, null means no reference.
 /// </param>
 /// <param name="relPosition">
 /// Position relative to reference star.
 /// </param>
 public StarTrackerByMax(Vector2D position, IStarTracker reference, Vector2D relPosition)
 {
     _position = position;
     _tolerance = 10.0f;
     _reference = reference;
     _movable = false;
     _relPosition = relPosition;
 }
Пример #9
0
 /// <summary>
 /// Creates StarTrackerByMax.
 /// </summary>
 /// <param name="position">
 /// Initial position of tracked object.
 /// </param>
 /// <param name="tolerance">
 /// Tolerance in star tracking.
 /// </param>
 /// <param name="reference">
 /// Reference star in tracking, null means no reference.
 /// </param>
 /// <param name="movable">
 /// Flag sets for movable object (planetoids, minor planets) and clear for static objects (stars)
 /// </param>
 public StarTrackerByMax(Vector2D position, float tolerance, IStarTracker reference, bool movable)
 {
     _position = position;
     _tolerance = tolerance;
     _reference = reference;
     _movable = movable;
     if (_reference != null)
         _relPosition = _position - _reference.Position;
 }
Пример #10
0
 public Point Transform(Vector2D data)
 {
     return new Point((int)LinearTransformX(data.X), (int)LinearTransformY(data.Y));
 }
Пример #11
0
 /// <summary>
 /// Create new DataSet.
 /// </summary>
 /// <param name="data">
 /// Data to plot.
 /// </param>
 /// <param name="plotPoint">
 /// Point type used on plot.
 /// </param>
 public DataSet(Vector2D[] data, IPlotPoint plotPoint)
 {
     _data = data;
     _plotPoint = plotPoint;
 }