public void DrawRectangle(Vector2D vMin, Vector2D vMax, Color penColor)
 {
     Point[] pt = TransformPoint(new Vector2D[] { vMin, vMax });
     System.Drawing.Graphics g = Graphics;
     Pen penRect = new Pen(penColor);
     g.DrawRectangle(penRect, pt[0].X, pt[0].Y, pt[1].X-pt[0].X, pt[1].Y-pt[0].Y);
 }
Exemple #2
0
        public static bool PointToAboveSegment(Vector2D p, Segment seg, ref double distance)
        {
            double xMin = System.Math.Min(seg.P0.X, seg.P1.X);
            double xMax = System.Math.Max(seg.P0.X, seg.P1.X);

            if (p.X < xMin - MathFunctions.EpsilonF || p.X > xMax + MathFunctions.EpsilonF)
                return false;
            else
            {
                double yMin = System.Math.Min(seg.P0.Y, seg.P1.Y);
                double yMax = System.Math.Max(seg.P0.Y, seg.P1.Y);

                if (System.Math.Abs(seg.P1.X - seg.P0.X) < MathFunctions.EpsilonF)
                {
                    if (p.Y < yMin)
                        distance = yMin - p.Y;
                    else if (p.Y > yMax)
                        distance = yMax - p.Y;
                    else
                        distance = 0.0f;
                }
                else
                    distance = seg.P0.Y + (p.X - seg.P0.X) * (seg.P1.Y - seg.P0.Y) / (seg.P1.X - seg.P0.X) - p.Y;
                return true;
            }
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Arc"/> class.
 /// </summary>
 /// <param name="arc">A <see cref="Arc"/> instance.</param>
 public Arc(Arc arc)
 {
     _pCenter = arc._pCenter;
     _radius = arc._radius;
     _angle0 = arc._angle0;
     _angle1 = arc._angle1;
 }
        public void AddPosition(LayerCyl layer, Vector2D vPosition)
        {
            Matrix4D matRot = Matrix4D.Identity;
            Vector3D vTranslation = Vector3D.Zero;

            if (_swapped)
            {
                matRot = new Matrix4D(
                    0.0, -1.0, 0.0, 0.0
                    , 1.0, 0.0, 0.0, 0.0
                    , 0.0, 0.0, 1.0, 0.0
                    , 0.0, 0.0, 0.0, 1.0
                    );
                vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0);
            }
            Transform3D transfRot = new Transform3D(matRot);

            matRot.M14 = vTranslation[0];
            matRot.M24 = vTranslation[1];
            matRot.M34 = vTranslation[2];

            Transform3D transfRotTranslation = new Transform3D(matRot);
            Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0));

            if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y)))
            {
                _log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Swapped = true", this.Name));
                return;
            }
            layer.Add(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y));
        }
 protected PicCotationDistance(uint id, Vector2D pt0, Vector2D pt1, double offset, short noDecimals)
     : base(id, noDecimals)
 {
     _pt0 = pt0;
     _pt1 = pt1;
     _offset = offset;
 }
 public void DrawLine(Vector2D v1, Vector2D v2, Color penColor)
 {
     Point[] pt = TransformPoint(new Vector2D[] { v1, v2 });
     System.Drawing.Graphics g = Graphics;
     Pen pen = new Pen(penColor);
     g.DrawLines(pen, pt);
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Arc"/> class.
 /// </summary>
 /// <param name="pCenter">A <see cref="Vector2D"/> instance marking the <see cref="Arc"/>'s center point.</param>
 /// <param name="radius">The <see cref="Arc"/>'s radius.</param>
 /// <param name="angle0">The <see cref="Arc"/>'s starting angle.</param>
 /// <param name="angle1">The <see cref="Arc"/>'s ending angle.</param>
 public Arc(Vector2D pCenter, float radius, float angle0, float angle1)
 {
     _pCenter = pCenter;
     _radius = radius;
     _angle0 = angle0;
     _angle1 = angle1;
 }
Exemple #8
0
 public static PicSegment CreateNewSegment(uint id, PicGraphics.LT lType, Vector2D pt0, Vector2D pt1)
 {
     PicSegment segment = new PicSegment(id, lType);
     segment._pt0 = pt0;
     segment._pt1 = pt1;
     return segment;
 }
Exemple #9
0
        static void Main(string[] args)
        {

            bool bestLayersOnly = true;
            Vector3D dimBox = new Vector3D(400.0, 300.0, 150.0);
            Vector2D dimContainer = new Vector2D(1200.0, 1000.0);
            ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
            constraintSet.SetMaxHeight(1200.0); 

            try
            {
                LayerSolver solver = new LayerSolver();
                List<Layer2D> layers = solver.BuildLayers(dimBox, dimContainer, constraintSet, bestLayersOnly);

                int solIndex = 0;
                foreach (Layer2D layer in layers)
                {
                    string fileName = string.Format("{0}_{1}.bmp", layer.Name, solIndex++);
                    string filePath = Path.Combine(Path.GetTempPath(), fileName);
                    Console.WriteLine(string.Format("Generating {0}...", filePath));

                    Graphics2DImage graphics = new Graphics2DImage( new Size(150, 150) );
                    SolutionViewerLayer solViewer = new SolutionViewerLayer(layer);
                    BoxProperties bProperties = new BoxProperties(null, 400.0, 300.0, 150.0);
                    bProperties.SetColor(Color.Brown);
                    solViewer.Draw(graphics, bProperties, 1500.0);
                    graphics.SaveAs(filePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #10
0
 public Bone(string name)
 {
     m_refPosition = new Vector2D(0.0, 0.0);
     m_mat = Matrix3D.Identity.Clone();
     m_totalMat = Matrix3D.Identity.Clone();
     m_name = name;
 }
 protected virtual bool IsMiddleQuotation(Vector2D pt2, Vector2D pt3, double textWidth, double textHeight)
 {
     double length = (pt3 - pt2).GetLength();
     if (Math.Abs(pt3.Y - pt2.Y) < (textHeight / textWidth) * Math.Abs(pt3.X - pt2.X))
         return Math.Abs((pt3 - pt2).X) > textWidth * _globalCotationProperties._lengthCoef;
     else
         return Math.Abs((pt3 - pt2).Y) > textHeight * _globalCotationProperties._lengthCoef;
 }
Exemple #12
0
        public List<Layer2D> BuildLayers(Vector3D dimBox, Vector2D dimContainer, ConstraintSetAbstract constraintSet, bool keepOnlyBest)
        {
            // instantiate list of layers
            List<Layer2D> listLayers0 = new List<Layer2D>();

            // loop through all patterns
            foreach (LayerPattern pattern in LayerPattern.All)
            {
                // loop through all orientation
                foreach (HalfAxis.HAxis axisOrtho in HalfAxis.All)
                {
                    // is orientation allowed
                    if ( !constraintSet.AllowOrientation(axisOrtho) )
                        continue;
                    // not swapped vs swapped pattern
                    for (int iSwapped = 0; iSwapped < 1; ++iSwapped)
                    {
                        // does swapping makes sense for this layer pattern ?
                        if (!pattern.CanBeSwapped && (iSwapped == 1))
                            continue;
                        // instantiate layer
                        Layer2D layer = new Layer2D(dimBox, dimContainer, axisOrtho, iSwapped == 1);
                        layer.PatternName = pattern.Name;
                        double actualLength = 0.0, actualWidth = 0.0;
                        if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
                            continue;
                        pattern.GenerateLayer(layer, actualLength, actualWidth);
                        if (0 == layer.Count)
                            continue;
                        listLayers0.Add(layer);
                    }
                }
            }

            // keep only best layers
            if (keepOnlyBest)
            {
                // 1. get best count
                int bestCount = 0;
                foreach (Layer2D layer in listLayers0)
                    bestCount = Math.Max(layer.CountInHeight(constraintSet.OptMaxHeight.Value), bestCount);

                // 2. remove any layer that does not match the best count given its orientation
                List<Layer2D> listLayers1 = new List<Layer2D>();
                foreach (Layer2D layer in listLayers0)
                {
                    if (layer.CountInHeight(constraintSet.OptMaxHeight.Value) >= bestCount)
                        listLayers1.Add(layer);
                }
                // 3. copy back in original list
                listLayers0.Clear();
                listLayers0.AddRange(listLayers1);
            }
            if (constraintSet.OptMaxHeight.Activated)
                listLayers0.Sort(new LayerComparerCount(constraintSet.OptMaxHeight.Value));

            return listLayers0;
        }
Exemple #13
0
        public override void DrawLine(LT lineType, Vector2D ptBeg, Vector2D ptEnd)
        {
            _cb.SetLineWidth(0.0f);
            _cb.SetColorStroke(LineTypeToBaseColor(lineType));

            _cb.MoveTo(DX(ptBeg.X), DY(ptBeg.Y));
            _cb.LineTo(DX(ptEnd.X), DY(ptEnd.Y));
            _cb.Stroke();
        }
Exemple #14
0
 public static PicArc CreateNewArc(uint id, PicGraphics.LT lType, Vector2D center, double radius, double angleBeg, double angleEnd)
 {
     PicArc arc = new PicArc(id, lType);
     arc._center = center;
     arc._radius = radius;
     arc._angleBeg = angleBeg;
     arc._angleEnd = angleEnd;
     return arc;
 }
            protected virtual void GetOffsetPoints(out Vector2D pt2, out Vector2D pt3)
            {
                // build normal
                Vector2D vI = (_pt1 - _pt0); vI.Normalize();
                Vector2D vJ = new Vector2D(vI.Y, -vI.X);
                double delta = -_globalCotationProperties._hrap;

                pt2 = new Vector2D(_pt0 + vJ * _offset + Math.Sign(_offset) * delta * vJ);
                pt3 = new Vector2D(_pt1 + vJ * _offset + Math.Sign(_offset) * delta * vJ);
            }
Exemple #16
0
 public static void DrawPoint(Graphics g, Vector2D vec, int width, int height)
 {
     Pen p = new Pen(Color.Red, 1);
     g.DrawEllipse(
         p,
         (float)(width * vec.X - 1.0),
         (float)(height * vec.Y - 1.0),
         3,
         3);
 }
Exemple #17
0
        //����������ϵ�еĶ������ù����任���ֲ�����ϵ��
        public Vector2D TransformPosition(Vector2D refPos)
        {
            //�����������ϵ�е�����
            Vector2D relPos = GetRelPositon(refPos);
            Vector3D homoPos = new Vector3D(relPos.X, relPos.Y, 1.0);

            //�ӹ�������ϵ�任���ֲ�����ϵ
            Vector3D TransformedPos = Matrix3D.Transform(m_totalMat, homoPos);
            return new Vector2D(TransformedPos.X, TransformedPos.Y);
        }
Exemple #18
0
        public override void DrawArc(PicGraphics.LT lineType, Vector2D ptCenter, double radius, double angle0, double angle1)
		{
            if (radius > 0.0)
            _gdiGraphics.DrawArc(ToPen(lineType)
                , X(ptCenter.X) - DX(radius)
                , Y(ptCenter.Y) - DY(radius)
                , (float)(2.0*DX(radius))	    // width
                , (float)(2.0*DY(radius))	    // height
                , -(float)angle0			    // start angle
                , -(float)(angle1-angle0));	    // sweep angle
		}
Exemple #19
0
        public void AddPosition(Layer layer, Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis)
        {
            Matrix4D matRot = Matrix4D.Identity;
            Vector3D vTranslation = Vector3D.Zero;

            if (_swapped && !layer.Inversed)
            {
                matRot = new Matrix4D(
                    0.0, -1.0, 0.0, 0.0
                    , 1.0, 0.0, 0.0, 0.0
                    , 0.0, 0.0, 1.0, 0.0
                    , 0.0, 0.0, 0.0, 1.0
                    );
                vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0);
            }
            else if (!_swapped && layer.Inversed)
            {
                matRot = new Matrix4D(
                    -1.0, 0.0, 0.0, 0.0
                    , 0.0, -1.0, 0.0, 0.0
                    , 0.0, 0.0, 1.0, 0.0
                    , 0.0, 0.0, 0.0, 1.0
                    );
                vTranslation = new Vector3D(layer.PalletLength, layer.PalletWidth, 0.0);
            }
            else if (_swapped && layer.Inversed)
            {
                matRot = new Matrix4D(
                    0.0, 1.0, 0.0, 0.0
                    , -1.0, 0.0, 0.0, 0.0
                    , 0.0, 0.0, 1.0, 0.0
                    , 0.0, 0.0, 0.0, 1.0
                    );
                vTranslation = new Vector3D(0.0, layer.PalletWidth, 0.0);
            }
            Transform3D transfRot = new Transform3D(matRot);
            HalfAxis.HAxis lengthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis)));
            HalfAxis.HAxis widthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis)));

            matRot.M14 = vTranslation[0];
            matRot.M24 = vTranslation[1];
            matRot.M34 = vTranslation[2];

            Transform3D transfRotTranslation = new Transform3D(matRot);
            Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0));

            if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped))
            {
                _log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Variant = {1}, Swapped = true", this.Name, _variantIndex));
                return;
            }
            layer.AddPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped);
        }
Exemple #20
0
 public FilmRectangle(
     Vector3D origin,
     HalfAxis.HAxis axis1, HalfAxis.HAxis axis2,
     Vector2D dimensions,
     double dBorder)
 {
     _origin = origin;
     _axis1 = axis1;
     _axis2 = axis2;
     _dimensions = dimensions;
     _dBorder = dBorder;
 }
Exemple #21
0
        public override void DrawArc(LT lineType, Vector2D ptCenter, double radius, double angleBeg, double angleEnd)
        {
            _cb.SetLineWidth(0.0f);
            _cb.SetColorStroke(LineTypeToBaseColor(lineType));

            _cb.Arc(
                DX(ptCenter.X-radius), DY(ptCenter.Y-radius)            // Bottom Left(x,y)
                , DX(ptCenter.X + radius), DY(ptCenter.Y + radius)      // Top Right(x,y)
                , -(float)angleBeg                                      // Start Angle
                , -(float)(angleEnd - angleBeg)                         // Extent
                );
            _cb.Stroke();
        }
Exemple #22
0
 public Layer2D BuildLayer(Vector3D dimBox, Vector2D dimContainer, LayerDesc layerDesc)
 {
     // instantiate layer
     Layer2D layer = new Layer2D(dimBox, dimContainer, layerDesc.AxisOrtho, false);
     // get layer pattern
     LayerPattern pattern = LayerPattern.GetByName(layerDesc.PatternName);
     // dimensions
     double actualLength = 0.0, actualWidth = 0.0;
     if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
         return null;
     pattern.GenerateLayer(layer, actualLength, actualWidth);
     return layer;
 }
Exemple #23
0
 public static bool PointToAboveArc(Vector2D p, Arc arc, ref double distance)
 {
     bool success = false;
     distance = double.MaxValue;
     IList<Segment> list = arc.Explode(20);
     foreach (Segment seg in list)
     {
         double dist = 0.0f;
         if (PointToAboveSegment(p, seg, ref dist) && dist > 0)
         {
             distance = System.Math.Min(dist, distance);
             success = true;
         }
     }
     return success;
 }
Exemple #24
0
        public void MinMax(double boxLength, double boxWidth, out Vector2D vMin, out Vector2D vMax)
        {
            Vector3D[] pts = new Vector3D[4];
            pts[0] = new Vector3D(_position.X, _position.Y, 0.0);
            pts[1] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength;
            pts[2] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_widthAxis) * boxWidth;
            pts[3] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength + HalfAxis.ToVector3D(_widthAxis) * boxWidth;

            vMin = new Vector2D(double.MaxValue, double.MaxValue);
            vMax = new Vector2D(double.MinValue, double.MinValue);
            foreach (Vector3D v in pts)
            {
                vMin.X = Math.Min(v.X, vMin.X);
                vMin.Y = Math.Min(v.Y, vMin.Y);
                vMax.X = Math.Max(v.X, vMax.X);
                vMax.Y = Math.Max(v.Y, vMax.Y);
            }
        }
            protected override void DrawArrowLine(PicGraphics graphics, Vector2D pt2, Vector2D pt3, double textWidth, double textHeight, out Vector2D ptText, out bool middle)
            {
                double length = (pt3 - pt2).GetLength();
                middle = length > textHeight * _globalCotationProperties._lengthCoef;

                double textX = (TextDirection == 270.0f) ? textHeight : textWidth;
                double textY = (TextDirection == 270.0f) ? textWidth : textHeight;

                if (middle)
                {
                    ptText = 0.5 * (pt2 + pt3);
                    graphics.DrawLine(LineType, pt2, pt2 + (pt3 - pt2) * 0.5 * (length - textY) / length);
                    graphics.DrawLine(LineType, pt2 + (pt3 - pt2) * 0.5 * (length + textY) / length, pt3);
                }
                else
                {
                    // text is on top
                    graphics.DrawLine(LineType, pt2, pt2 + (pt3 - pt2) * _globalCotationProperties._lengthCoef);
                    ptText = pt2 + (pt3 - pt2) * ((_globalCotationProperties._lengthCoef * length + 0.5 * textX) / length);
                }
            }
            protected override void DrawArrowLine(PicGraphics graphics, Vector2D pt2, Vector2D pt3, double textWidth, double textHeight, out Vector2D ptText, out bool middle)
            {
                double length = (pt3 - pt2).GetLength();
                middle = length > textWidth * _globalCotationProperties._lengthCoef;

                if (middle)
                {
                    ptText = 0.5 * (pt2 + pt3);
                    graphics.DrawLine(LineType, pt2, pt2 + (pt3 - pt2) * 0.5 * (length - textWidth) / length);
                    graphics.DrawLine(LineType, pt2 + (pt3 - pt2) * 0.5 * (length + textWidth) / length, pt3);
                }
                else
                { 
                    // text is on the right
                    Vector2D ptLeft = new Vector2D(pt2.X < pt3.X ? pt2 : pt3);
                    Vector2D ptRight = new Vector2D(pt2.X < pt3.X ? pt3 : pt2);

                    graphics.DrawLine(LineType, pt2, pt2 + (pt3 - pt2) * _globalCotationProperties._lengthCoef);
                    ptText =  pt2 + (pt3 - pt2) * ((_globalCotationProperties._lengthCoef*length + 0.5*textWidth) / length);
                }
            }
Exemple #27
0
		/// <summary>
		/// Calculates the squared distance between a point and a segment.
		/// </summary>
		/// <param name="point">A <see cref="Vector2D"/> instance.</param>
		/// <param name="segment">A <see cref="Segment"/> instance.</param>
		/// <returns>The squared distance between the point and the segment.</returns>
		public static double SquaredDistance(Vector2D point, Segment segment)
		{
            Vector2D D = segment.P1 - segment.P0;
            Vector2D diffPointP0 = point - segment.P0;
            double t = Vector2D.DotProduct(D, diffPointP0);

			if (t <= 0)
			{
				// segment.P0 is the closest to point.
                return Vector2D.DotProduct(diffPointP0, diffPointP0);
			}

            double DdD = Vector2D.DotProduct(D, D);
			if (t >= DdD)
			{
				// segment.P1 is the closest to point.
                Vector2D diffPointP1 = point - segment.P1;
                return Vector2D.DotProduct(diffPointP1, diffPointP1);
			}
			
			// Closest point is inside the segment.
            return Vector2D.DotProduct(diffPointP0, diffPointP0) - t * t / DdD;
		}
Exemple #28
0
 public bool GetReferencePointAndThickness(ref Vector2D v, ref double thickness)
 {
     if (!Component.IsSupportingAutomaticFolding)
         return false;
     ParameterStack stack = CurrentParameterStack;
     thickness = stack.GetDoubleParameterValue("th1");
     v = Component.ReferencePoint(stack);
     return true;
 }
Exemple #29
0
        private void Panel1_MouseMove(object sender, MouseEventArgs e)
        {
            Panel1.Focus();
            try
            {
                if (e.Button == MouseButtons.Left)
                {
                    Point ptDiff = new Point(e.Location.X - _mousePositionPrev.X, e.Location.Y - _mousePositionPrev.Y);
                    double aspectRatio = 1.0;

                    Box2D box = _picGraphics.DrawingBox;

                    Vector2D centerScreen = new Vector2D(
                        box.Center.X - (double)ptDiff.X * box.Width / (double)Panel1.ClientSize.Width
                        , box.Center.Y + (double)ptDiff.Y * box.Height / ((double)Panel1.ClientSize.Height * aspectRatio));
                    box.Center = centerScreen;
                    _picGraphics.DrawingBox = box;

                    Panel1.Invalidate();
                }
                _mousePositionPrev = e.Location;
            }
            catch (InvalidBoxException /*ex*/)
            {
                _computeBbox = true;
            }
            catch (Exception ex)
            {
                _log.Debug(ex.ToString());
            }
            finally
            {
            }
        }
Exemple #30
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Matrix2D"/> structure with the specified values.
		/// </summary>
		/// <param name="column1">A <see cref="Vector2D"/> instance holding values for the first column.</param>
		/// <param name="column2">A <see cref="Vector2D"/> instance holding values for the second column.</param>
		public Matrix2D(Vector2D column1, Vector2D column2)
		{
			_m11 = column1.X; _m12 = column2.X;
			_m21 = column1.Y; _m22 = column2.Y;
		}
Exemple #31
0
		/// <summary>
		/// Transforms a given vector by a matrix and put the result in a vector.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix2D"/> instance.</param>
		/// <param name="vector">A <see cref="Vector2D"/> instance.</param>
		/// <param name="result">A <see cref="Vector2D"/> instance to hold the result.</param>
		public static void Transform(Matrix2D matrix, Vector2D vector, ref Vector2D result)
		{
			result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y);
			result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y);
		}
Exemple #32
0
 public static Vector2D ConvertLengthFrom(Vector2D value, UnitsManager.UnitSystem unitSystem)
 {
     if (unitSystem == CurrentUnitSystem)
         return value;
     else
     {
         StandardMeasure<Length> measureX = new StandardMeasure<Length>(value.X, LengthUnitFromUnitSystem(unitSystem));
         StandardMeasure<Length> measureY = new StandardMeasure<Length>(value.Y, LengthUnitFromUnitSystem(unitSystem));
         return new Vector2D(
             measureX.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem))
             , measureY.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem))
             );
     }        
 }
Exemple #33
0
		/// <summary>
		/// Transforms a given vector by a matrix.
		/// </summary>
		/// <param name="matrix">A <see cref="Matrix2D"/> instance.</param>
		/// <param name="vector">A <see cref="Vector2D"/> instance.</param>
		/// <returns>A new <see cref="Vector2D"/> instance containing the result.</returns>
		public static Vector2D Transform(Matrix2D matrix, Vector2D vector)
		{
			return new Vector2D(
				(matrix.M11 * vector.X) + (matrix.M12 * vector.Y),
				(matrix.M21 * vector.X) + (matrix.M22 * vector.Y));
		}