本文整理汇总了C#中System.Vector2.getScaled方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.getScaled方法的具体用法?C# Vector2.getScaled怎么用?C# Vector2.getScaled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.getScaled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: findNearestPositionWhereMapIs
//
// Zzzzz
// zYyyz
// zyXyz
// zyyyz
// zzzzz
//
public static Vector2<int> findNearestPositionWhereMapIs(bool value, Vector2<int> position, Map2d<bool> image, uint radius, out bool found)
{
Vector2<int> outwardIteratorOffsetUnbound;
Vector2<int> borderMin;
Vector2<int> borderMax;
Vector2<int> one;
Vector2<int> positionAsInt;
found = false;
outwardIteratorOffsetUnbound = new Vector2<int>();
outwardIteratorOffsetUnbound.x = 0;
outwardIteratorOffsetUnbound.y = 0;
borderMin = new Vector2<int>();
borderMin.x = 0;
borderMin.y = 0;
borderMax = new Vector2<int>();
borderMax.x = (int)image.getWidth();
borderMax.y = (int)image.getLength();
positionAsInt = new Vector2<int>();
positionAsInt.x = (int)position.x;
positionAsInt.y = (int)position.y;
one = new Vector2<int>();
one.x = 1;
one.y = 1;
for(;;)
{
Vector2<int> iteratorOffsetBoundMin;
Vector2<int> iteratorOffsetBoundMax;
int x, y;
if (-outwardIteratorOffsetUnbound.x > radius)
{
break;
}
iteratorOffsetBoundMin = Vector2<int>.max(borderMin, outwardIteratorOffsetUnbound + positionAsInt, outwardIteratorOffsetUnbound + positionAsInt, outwardIteratorOffsetUnbound + positionAsInt);
iteratorOffsetBoundMax = Vector2<int>.min(borderMax, outwardIteratorOffsetUnbound.getScaled(-1) + one + positionAsInt, borderMax, borderMax);
for (y = (int)(iteratorOffsetBoundMin.y); y < iteratorOffsetBoundMax.y; y++ )
{
for( x = (int)(iteratorOffsetBoundMin.x); x < iteratorOffsetBoundMax.x; x++ )
{
// just find at the border
if (y == (int)(iteratorOffsetBoundMin.y) || y == iteratorOffsetBoundMax.y - 1 || x == (int)(iteratorOffsetBoundMin.x) || x == iteratorOffsetBoundMax.x - 1)
{
bool valueAtPoint;
valueAtPoint = image.readAt(x, y);
if (valueAtPoint == value)
{
found = true;
Vector2<int> result;
result = new Vector2<int>();
result.x = x;
result.y = y;
return result;
}
}
}
}
outwardIteratorOffsetUnbound.x--;
outwardIteratorOffsetUnbound.y--;
}
found = false;
return new Vector2<int>();
}
示例2: calculateRelativePositionsForRadius
//
// Zzzzz
// zYyyz
// zyXyz
// zyyyz
// zzzzz
//
private static List<Vector2<int>> calculateRelativePositionsForRadius(int radius)
{
List<Vector2<int>> resultOffsets;
Vector2<int> outwardIteratorOffsetUnbound;
Vector2<int> one;
outwardIteratorOffsetUnbound = new Vector2<int>();
outwardIteratorOffsetUnbound.x = 0;
outwardIteratorOffsetUnbound.y = 0;
one = new Vector2<int>();
one.x = 1;
one.y = 1;
resultOffsets = new List<Vector2<int>>();
for (; ; )
{
Vector2<int> iteratorOffsetBoundMin;
Vector2<int> iteratorOffsetBoundMax;
int x, y;
if (-outwardIteratorOffsetUnbound.x > radius)
{
break;
}
iteratorOffsetBoundMin = outwardIteratorOffsetUnbound;
iteratorOffsetBoundMax = outwardIteratorOffsetUnbound.getScaled(-1) + one;
for (y = (int)(iteratorOffsetBoundMin.y); y < iteratorOffsetBoundMax.y; y++)
{
for (x = (int)(iteratorOffsetBoundMin.x); x < iteratorOffsetBoundMax.x; x++)
{
// just add the border
if( y == (int)(iteratorOffsetBoundMin.y) || y == iteratorOffsetBoundMax.y - 1 || x == (int)(iteratorOffsetBoundMin.x) || x == iteratorOffsetBoundMax.x - 1 )
{
Vector2<int> newOffset;
newOffset = new Vector2<int>();
newOffset.x = x;
newOffset.y = y;
resultOffsets.Add(newOffset);
}
}
}
outwardIteratorOffsetUnbound.x--;
outwardIteratorOffsetUnbound.y--;
}
return resultOffsets;
}