当前位置: 首页>>代码示例>>C#>>正文


C# Transform.Estimate方法代码示例

本文整理汇总了C#中System.Windows.Media.Transform.Estimate方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.Estimate方法的具体用法?C# Transform.Estimate怎么用?C# Transform.Estimate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Transform的用法示例。


在下文中一共展示了Transform.Estimate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildMachineCoordinateData_m


//.........这里部分代码省略.........
                        double.TryParse(Row.Cells["X_nominal"].Value.ToString(), out X_nom);
                        double.TryParse(Row.Cells["Y_nominal"].Value.ToString(), out Y_nom);
                        break;
                    }
                }
                Fiducials[i].X_nominal = X_nom;
                Fiducials[i].Y_nominal = Y_nom;
                // And measure it's true location:
                if (!MeasureFiducial_m(ref Fiducials[i]))
                {
                    return false;
                }
                // We could put the machine data in place at this point. However, 
                // we don't, as if the algorithms below are correct, the data will not change more than measurement error.
                // During development, that is a good checkpoint.
            }

            // Find the homographic tranformation from CAD data (fiducials.nominal) to measured machine coordinates
            // (fiducials.machine):
            Transform transform = new Transform();
            HomographyEstimation.Point[] nominals = new HomographyEstimation.Point[Fiducials.Length];
            HomographyEstimation.Point[] measured = new HomographyEstimation.Point[Fiducials.Length];
            // build point data arrays:
            for (int i = 0; i < Fiducials.Length; i++)
            {
                nominals[i].X = Fiducials[i].X_nominal;
                nominals[i].Y = Fiducials[i].Y_nominal;
                nominals[i].W = 1.0;
                measured[i].X = Fiducials[i].X_machine;
                measured[i].Y = Fiducials[i].Y_machine;
                measured[i].W = 1.0;
            }
            // find the tranformation
            bool res = transform.Estimate(nominals, measured, ErrorMetric.Transfer, 450, 450);  // the PCBs are smaller than 450mm
            if (!res)
            {
                ShowMessageBox(
                    "Transform estimation failed.",
                    "Data error",
                    MessageBoxButtons.OK);
                return false;
            }
            // Analyze the transform: Displacement is for debug. We could also calculate X & Y stretch and shear, but why bother.
            // Find out the displacement in the transform (where nominal origin ends up):
            HomographyEstimation.Point Loc, Loc2;
            Loc.X = 0.0;
            Loc.Y = 0.0;
            Loc.W = 1.0;
            Loc = transform.TransformPoint(Loc);
            Loc = Loc.NormalizeHomogeneous();
            DisplayText("Transform:");
            DisplayText("dX= " + (Loc.X).ToString());
            DisplayText("dY= " + Loc.Y.ToString());
            // We do need rotation. Find out by rotatíng a unit vector:
            Loc2.X = 1.0;
            Loc2.Y = 0.0;
            Loc2.W = 1.0;
            Loc2 = transform.TransformPoint(Loc2);
            Loc2 = Loc2.NormalizeHomogeneous();
            DisplayText("dX= " + Loc2.X.ToString());
            DisplayText("dY= " + Loc2.Y.ToString());
            double angle = Math.Asin(Loc2.Y - Loc.Y) * 180.0 / Math.PI; // in degrees
            DisplayText("angle= " + angle.ToString());

            // Calculate machine coordinates of all components:
            foreach (DataGridViewRow Row in CadData_GridView.Rows)
开发者ID:mrandt,项目名称:LitePlacer-DEV,代码行数:67,代码来源:MainForm.cs


注:本文中的System.Windows.Media.Transform.Estimate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。