本文整理汇总了C#中VectorF.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# VectorF.GetLength方法的具体用法?C# VectorF.GetLength怎么用?C# VectorF.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorF
的用法示例。
在下文中一共展示了VectorF.GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBoundingArea
public static BoundingArea GetBoundingArea(float x1, float y1, float x2, float y2)
{
#if !SIMPLE_BOUNDING_AREA
if (x1 == x2 || y1 == y2) { return new BoundingArea(VisualizationUtils.CreateRectangle(x1, y1, x2, y2)); }
float delta = Math.Abs((x2 - x1) / (y2 - y1));
float stepMax = (float)Math.Sqrt(mMaxBoxArea / delta + delta * mMaxBoxArea);
VectorF line = new VectorF(x1, y1, x2, y2);
float lineLen = line.GetLength();
if (stepMax >= lineLen) { return new BoundingArea(VisualizationUtils.CreateRectangle(x1, y1, x2, y2)); }
BoundingArea boundingArea = new BoundingArea();
int steps = (int)Math.Ceiling(lineLen / stepMax);
VectorF stepVec = line;
stepVec.SetLength(lineLen / (float)steps);
VectorF pt1 = new VectorF(x1, y1);
VectorF pt2;
for (int i = 0; i < steps - 1; i++)
{
pt2 = pt1 + stepVec;
boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(pt1.X, pt1.Y, pt2.X, pt2.Y));
pt1 = pt2;
}
pt2 = new VectorF(x2, y2);
boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(pt1.X, pt1.Y, pt2.X, pt2.Y));
return boundingArea;
#else
BoundingArea boundingArea = new BoundingArea();
boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(x1, y1, x2, y2));
return boundingArea;
#endif
}