public void Transform(ITransform2 xform)
 {
     foreach (var c in this.curves)
     {
         c.Transform(xform);
     }
 }
Exemple #2
0
 public void Transform(ITransform2 xform)
 {
     for (int k = 0; k < mCtrlPoint.Length; ++k)
     {
         mCtrlPoint[k] = xform.TransformP(mCtrlPoint[k]);
     }
 }
        public void Transform(ITransform2 xform)
        {
            for (int k = 0; k < mCtrlPoint.Length; ++k)
            {
                mCtrlPoint[k] = xform.TransformP(mCtrlPoint[k]);
            }

            // update derivatives
            for (int i = 0; i < mNumCtrlPoints - 1; ++i)
            {
                mDer1CtrlPoint[i] = mCtrlPoint[i + 1] - mCtrlPoint[i];
            }

            for (int i = 0; i < mNumCtrlPoints - 2; ++i)
            {
                mDer2CtrlPoint[i] = mDer1CtrlPoint[i + 1] - mDer1CtrlPoint[i];
            }

            if (mDegree >= 3)
            {
                for (int i = 0; i < mNumCtrlPoints - 3; ++i)
                {
                    mDer3CtrlPoint[i] = mDer2CtrlPoint[i + 1] - mDer2CtrlPoint[i];
                }
            }
        }
Exemple #4
0
        public void Transform(ITransform2 xform)
        {
            Vector2d vCenter = xform.TransformP(Center);
            Vector2d vStart  = xform.TransformP((IsReversed) ? P1 : P0);
            Vector2d vEnd    = xform.TransformP((IsReversed) ? P0 : P1);

            SetFromCenterAndPoints(vCenter, vStart, vEnd);
        }
Exemple #5
0
 public void Transform(ITransform2 xform)
 {
     Center   = xform.TransformP(Center);
     Axis0    = xform.TransformN(Axis0);
     Axis1    = xform.TransformN(Axis1);
     Extent.x = xform.TransformScalar(Extent.x);
     Extent.y = xform.TransformScalar(Extent.y);
 }
 public TransformSequence2 Append(ITransform2 t2)
 {
     Operations.Add(new XForm()
     {
         type  = XFormType.NestedITransform2,
         xform = t2
     });
     return(this);
 }
Exemple #7
0
        public Polygon2d Transform(ITransform2 xform)
        {
            int N = vertices.Count;

            for (int k = 0; k < N; ++k)
            {
                vertices[k] = xform.TransformP(vertices[k]);
            }
            return(this);
        }
Exemple #8
0
 public static Matrix2x3d ToMatrix(this ITransform2 transform)
 {
     if (transform is Transform2Identity)
     {
         return(Matrix2x3d.Identity);
     }
     if (transform is Transform2Matrix)
     {
         return(((Transform2Matrix)transform).Matrix);
     }
     throw new NotSupportedException();
 }
Exemple #9
0
        public ClothoidArc2(ITransform2 transform,
                            double l0, double l1,
                            bool invertY, double a)
        {
            this.l0      = l0;
            this.l1      = l1;
            this.A       = a;
            this.InvertY = invertY;

            this.transform = transform;

            this.SetTInterval(this.l0, this.l1);
        }
Exemple #10
0
        public void Transform(ITransform2 xform)
        {
            Center = xform.TransformP(Center);
            Vector2d new_P0 = xform.TransformP(P0) - Center;

            AngleStartDeg = Math.Atan2(new_P0.y, new_P0.x);
            Vector2d new_P1 = xform.TransformP(P1) - Center;

            AngleEndDeg = Math.Atan2(new_P1.y, new_P1.x);
            if (AngleEndDeg < AngleStartDeg)
            {
                AngleEndDeg += 360;
            }

            Radius = xform.TransformScalar(Radius);
        }
        public override ITransform2 Concat(ITransform2 transform)
        {
            if (transform is Transform2Identity)
            {
                return(transform);
            }

            Transform2Matrix tmatrix = transform as Transform2Matrix;

            if (tmatrix == null)
            {
                throw new NotImplementedException();
            }

            Matrix2x3d result = this.Matrix.Clone();

            result.Mul(tmatrix.Matrix);
            return(new Transform2Matrix(result, true));
        }
        public void Transform(ITransform2 xform, bool bApplyToSources, bool bRecomputePolygons = false)
        {
            foreach (var element in vElements)
            {
                if (element is SmoothLoopElement)
                {
                    var loop = element as SmoothLoopElement;
                    if (bApplyToSources && loop.source != loop.polygon)
                    {
                        loop.source.Transform(xform);
                    }

                    if (bRecomputePolygons)
                    {
                        UpdateSampling(loop);
                    }
                    else
                    {
                        loop.polygon.Transform(xform);
                    }
                }
                else if (element is SmoothCurveElement)
                {
                    var curve = element as SmoothCurveElement;
                    if (bApplyToSources && curve.source != curve.polyLine)
                    {
                        curve.source.Transform(xform);
                    }

                    if (bRecomputePolygons)
                    {
                        UpdateSampling(curve);
                    }
                    else
                    {
                        curve.polyLine.Transform(xform);
                    }
                }
            }
        }
Exemple #13
0
        public static ClothoidArc2[] Split(double tmin,
                                           Point2d point0, Point2d point1,
                                           double radius0, double radius1,
                                           double a)
        {
            bool invertY = (radius1 < 0);

            double l0_n = ClothoUtils.ClothoL(radius0, invertY, a);
            double l1_n = ClothoUtils.ClothoL(radius1, invertY, a);

            Contract.Assert(l0_n < 0 && l1_n > 0);

            // Coordenadas en el punto (0) y (1) para una clotoide normalizada.
            Point2d p0_n = ClothoUtils.Clotho(l0_n, invertY, a);
            Point2d p1_n = ClothoUtils.Clotho(l1_n, invertY, a);

            // Diferencia de puntos en coordenadas reales.
            Vector2d v01 = point1.Sub(point0);

            Vector2d v01_n = p1_n.Sub(p0_n);

            // Rotacion de v01_n -> v01.
            double r = v01_n.AngleTo(v01);

            // Transformacion a aplicar.
            ITransform2 transform = Transform2.Translate(point1.X - p1_n.X, point1.Y - p1_n.Y)
                                    .Concat(Transform2.Rotate(p1_n.X, p1_n.Y, r));

            ClothoidArc2 left  = new ClothoidArc2(transform, l0_n, 0, invertY, a);
            ClothoidArc2 right = new ClothoidArc2(transform, 0, l1_n, invertY, a);

            left.SetTInterval(tmin, tmin + (-l0_n)); // l0_n < 0
            right.SetTInterval(tmin + (-l0_n), tmin + (-l0_n) + l1_n);

            return(new[] { left, right });
        }
Exemple #14
0
 public void Transform(ITransform2 xform, bool bApplyToSources)
 {
     foreach (var element in vElements)
     {
         if (element is SmoothLoopElement)
         {
             var loop = element as SmoothLoopElement;
             loop.polygon.Transform(xform);
             if (bApplyToSources && loop.source != loop.polygon)
             {
                 loop.source.Transform(xform);
             }
         }
         else if (element is SmoothCurveElement)
         {
             var curve = element as SmoothCurveElement;
             curve.polyLine.Transform(xform);
             if (bApplyToSources && curve.source != curve.polyLine)
             {
                 curve.source.Transform(xform);
             }
         }
     }
 }
Exemple #15
0
        public static ClothoidArc2 BuildSimple(double radius0, double radius1, double a, ITransform2 transform)
        {
            // Correccion sobre los radios.
            if (SysMath.Sign(radius1) != SysMath.Sign(radius0))
            {
                if (double.IsInfinity(radius0))
                {
                    radius0 = SysMath.Sign(radius1) * double.PositiveInfinity;
                }
                else if (double.IsInfinity(radius1))
                {
                    radius1 = SysMath.Sign(radius0) * double.PositiveInfinity;
                }
                else
                {
                    // No se permite cambio de signo en el radio. Funcionaria???
                    Contract.Assert(false);
                }
            }

            // Desarrollo segun el radio en el punto (0) y (1).
            double l0 = ClothoUtils.ClothoL(radius0, false, a);
            double l1 = ClothoUtils.ClothoL(radius1, false, a);

            ClothoidArc2 clotho = new ClothoidArc2(transform, l0, l1, false, a);

            clotho.SetTInterval(0, Math.Abs(l1 - l0));
            return(clotho);
        }
Exemple #16
0
 public static BoundingBox2d DoTransform(this ITransform2 transform, BoundingBox2d bbox)
 {
     return(BoundingBox2d.UnionOfPoints(bbox.GetVertices().Select(v => transform.DoTransform(v))));
 }
Exemple #17
0
 public override ITransform2 Concat(ITransform2 transform)
 {
     return(transform);
 }
Exemple #18
0
 public void Transform(ITransform2 xform)
 {
     Center = xform.TransformP(Center);
     Radius = xform.TransformScalar(Radius);
 }
Exemple #19
0
 public void Transform(ITransform2 xform)
 {
     Center    = xform.TransformP(Center);
     Direction = xform.TransformN(Direction);
     Extent    = xform.TransformScalar(Extent);
 }
Exemple #20
0
 public abstract ITransform2 Concat(ITransform2 transform);
Exemple #21
0
 public void Transform(ITransform2 xform)
 {
     Polyline.Transform(xform);
 }
Exemple #22
0
        public static ClothoidArc2 BuildSimple(double tmin,
                                               Point2d point0, Point2d point1,
                                               double radius0, double radius1,
                                               double a)
        {
            // Correccion sobre los radios.
            if (SysMath.Sign(radius1) != SysMath.Sign(radius0))
            {
                if (double.IsInfinity(radius0))
                {
                    radius0 = SysMath.Sign(radius1) * double.PositiveInfinity;
                }
                else if (double.IsInfinity(radius1))
                {
                    radius1 = SysMath.Sign(radius0) * double.PositiveInfinity;
                }
                else
                {
                    // No se permite cambio de signo en el radio. Funcionaria???
                    Contract.Assert(false);
                }
            }

            bool invertY;

            if (SysMath.Abs(radius0) > SysMath.Abs(radius1))
            {
                // t positivas
                invertY = radius1 < 0;
            }
            else
            {
                // t negativa
                invertY = radius1 > 0;
            }

            // Diferencia de puntos en coordenadas reales.
            Vector2d v01 = point1.Sub(point0);

            // Desarrollo segun el radio en el punto (0) y (1).
            double l0_n = ClothoUtils.ClothoL(radius0, invertY, a);
            double l1_n = ClothoUtils.ClothoL(radius1, invertY, a);

            // Coordenadas en el punto (0) y (1) para una clotoide normalizada.
            Point2d p0_n = ClothoUtils.Clotho(l0_n, invertY, a);
            Point2d p1_n = ClothoUtils.Clotho(l1_n, invertY, a);

            Vector2d v01_n = p1_n.Sub(p0_n);

            // Rotacion de v01_n -> v01.
            double r = v01_n.AngleTo(v01);

            // Transformacion a aplicar.
            ITransform2 transform = Transform2.Translate(point1.X - p1_n.X, point1.Y - p1_n.Y)
                                    .Concat(Transform2.Rotate(p1_n.X, p1_n.Y, r));

            double l0 = l0_n;
            double l1 = l1_n;

            ClothoidArc2 clotho = new ClothoidArc2(transform, l0, l1, invertY, a);

            clotho.SetTInterval(tmin, tmin + Math.Abs(l1 - l0));
            return(clotho);
        }
Exemple #23
0
 public static Point2d DoTransform(this ITransform2 transform, Point2d p)
 {
     return(transform.Transform(p).ToPoint2d());
 }
Exemple #24
0
 public void Transform(ITransform2 xform)
 {
     Polygon.Transform(xform);
 }
Exemple #25
0
 public static Vector2d DoTransform(this ITransform2 transform, Vector2d v)
 {
     return(transform.Transform(v).ToVector2d());
 }