本文整理汇总了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)