本文整理汇总了C#中System.Windows.Media.Transform.TransformPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.TransformPoint方法的具体用法?C# Transform.TransformPoint怎么用?C# Transform.TransformPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Transform
的用法示例。
在下文中一共展示了Transform.TransformPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMachineCoordinateData_m
//.........这里部分代码省略.........
}
// 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)
{
// build a point from CAD data values
double.TryParse(Row.Cells["X_nominal"].Value.ToString(), out Loc.X);
double.TryParse(Row.Cells["Y_nominal"].Value.ToString(), out Loc.Y);
Loc.W = 1;
// transform it
Loc = transform.TransformPoint(Loc);
Loc = Loc.NormalizeHomogeneous();
// store calculated location values
Row.Cells["X_machine"].Value = Loc.X.ToString("0.000", CultureInfo.InvariantCulture);
Row.Cells["Y_machine"].Value = Loc.Y.ToString("0.000", CultureInfo.InvariantCulture);
// handle rotation
double rot;
double.TryParse(Row.Cells["Rotation"].Value.ToString(), out rot);
rot += angle;