Beispiel #1
0
 /// <summary>
 /// Transforms a point according to the affine transformation.
 /// </summary>
 /// <param name="inV">the input 2D point.</param>
 /// <returns>the transformed point.</returns>
 public SySal.BasicTypes.Vector2 Transform(SySal.BasicTypes.Vector2 inV)
 {
     SySal.BasicTypes.Vector2 v = new SySal.BasicTypes.Vector2();
     v.X = MXX * (inV.X - RX) + MXY * (inV.Y - RY) + TX + RX;
     v.Y = MYX * (inV.X - RX) + MYY * (inV.Y - RY) + TY + RY;
     return(v);
 }
Beispiel #2
0
 /// <summary>
 /// Deforms a vector using the linear deformation.
 /// </summary>
 /// <param name="inV">the input vector.</param>
 /// <returns>the transformed vector.</returns>
 public SySal.BasicTypes.Vector2 Deform(SySal.BasicTypes.Vector2 inV)
 {
     SySal.BasicTypes.Vector2 v = new SySal.BasicTypes.Vector2();
     v.X = MXX * inV.X + MXY * inV.Y;
     v.Y = MYX * inV.X + MYY * inV.Y;
     return(v);
 }
Beispiel #3
0
        /// <summary>
        /// Seeks the kink.
        /// </summary>
        /// <param name="segs">the array of segments to use.</param>
        /// <param name="allowedkink">the number of entries must be equal to the number of segments minus 1, since differences matter; then, the kink is checked for segments whose corresponding entry is set to <c>true</c> in this array.</param>
        protected void ComputeResult(SySal.TotalScan.Segment[] segs, bool[] allowedkink)
        {
            TransverseSlopeRMS = LongitudinalSlopeRMS = TransverseMaxDeltaSlopeRatio = LongitudinalMaxDeltaSlopeRatio = KinkDelta = -1.0;
            KinkIndex          = -1;
            KinkDelta          = -1.0;
            int    i;
            int    j = 0;
            double rmst = 0.0, rmsl = 0.0;

            for (i = 1; i < segs.Length; i++)
            {
                SySal.BasicTypes.Vector2 r = SlopeDiff(segs[i].Info.Slope, segs[i - 1].Info.Slope, segs[i].Info.Intercept.Z, segs[i - 1].Info.Intercept.Z);
                if (r.X >= 0.0 && r.Y >= 0.0)
                {
                    j++;
                    rmsl += r.X * r.X;
                    rmst += r.Y * r.Y;
                }
            }
            if (j < 2)
            {
                return;
            }
            KinkDelta = 0.0;
            double newr;

            TransverseSlopeRMS   = Math.Sqrt(rmst / j);
            LongitudinalSlopeRMS = Math.Sqrt(rmsl / j);
            if (allowedkink.Length != segs.Length - 1)
            {
                ExceptionMessage = "The number of segments and of kink search activation flags must be identical";
                return;
            }
            if (allowedkink.Length < 3)
            {
                ExceptionMessage = "Kink search requires at least 3 segments.";
                return;
            }
            for (i = 0; i < allowedkink.Length; i++)
            {
                if (allowedkink[i])
                {
                    SySal.BasicTypes.Vector2 r = SlopeDiff(segs[i + 1].Info.Slope, segs[i].Info.Slope, segs[i + 1].Info.Intercept.Z, segs[i].Info.Intercept.Z);
                    if (r.X < 0.0 || r.Y < 0.0)
                    {
                        continue;
                    }
                    double rl = r.X / Math.Sqrt((rmsl - r.X * r.X) / (j - 1));
                    double rt = r.Y / Math.Sqrt((rmst - r.Y * r.Y) / (j - 1));
                    if ((newr = (rl * rl + rt * rt)) > KinkDelta)
                    {
                        KinkIndex = i;
                        TransverseMaxDeltaSlopeRatio   = rt;
                        LongitudinalMaxDeltaSlopeRatio = rl;
                        KinkDelta = newr;
                    }
                }
            }
            KinkDelta        = Math.Sqrt(KinkDelta);
            ExceptionMessage = null;
        }