本文整理汇总了C#中System.Vector2.scale方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.scale方法的具体用法?C# Vector2.scale怎么用?C# Vector2.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
lastPointPosition.y = 0;
// iterate throug the permutation and pick out the elements which are points, connect them with (colorcoded) lines
int permutationIndex;
for (permutationIndex = 0; permutationIndex < resultBestPermutation.Count; permutationIndex++)
{
int permutationElement;
permutationElement = resultBestPermutation[permutationIndex];
// div by 2 because we store until now only single floats
if (permutationElement < pointCoordinates.Count / 2)
{
Vector2<int> pointPosition;
pointPosition = new Vector2<int>();
pointPosition.x = 0 + (int)((float)480 * (pointCoordinates[permutationElement * 2 + 0] / 10.0f));
pointPosition.y = 0 + (int)((float)480 * (pointCoordinates[permutationElement * 2 + 1] / 10.0f));
drawingGraphics.DrawLine(penBlue, lastPointPosition.x, lastPointPosition.y, pointPosition.x, pointPosition.y);
lastPointPosition = pointPosition;
}
}
drawingGraphics.Flush();
drawingBitmap.Save("C:\\Users\\r0b3\\temp\\connectedPoints.png");
int sdksfdjksfdjklsfdjkl = 0;
}
Map2d<ColorRgb> imageColor;
Map2d<float> grayscaleImage;
imageColor = new Map2d<ColorRgb>(1280, 720);
for (imageNumber = 0; imageNumber < numberOfImages; imageNumber++)
{
// indicates if we need to reseed the points we track
bool reseedTrackingPoints;
Console.WriteLine(imageNumber.ToString());
Stopwatch stopwatch;
stopwatch = new Stopwatch();
{
Image readImage;
metric.startTimer("visual", "read image", "");
readImage = Image.FromFile(pathToInputImages + (imageNumber + 1).ToString() + ".png");
metric.stopTimer();
// convert it to white/black image
Bitmap workingBitmap = new Bitmap(readImage);
grayscaleImage = new Map2d<float>((uint)workingBitmap.Width, (uint)workingBitmap.Height);
//imageRComponent = new Map2d<float>((uint)workingBitmap.Width, (uint)workingBitmap.Height);
//imageGComponent = new Map2d<float>((uint)workingBitmap.Width, (uint)workingBitmap.Height);
//imageBComponent = new Map2d<float>((uint)workingBitmap.Width, (uint)workingBitmap.Height);
int x, y;
示例2: call
public void call(List<Datastructures.Variadic> parameters, out Datastructures.Variadic result, out GeneticProgramming.TypeRestrictedOperator.EnumResult resultCode)
{
int i;
List<Vector2<float>>[] groups;
int groupI;
Datastructures.TreeNode groupsTreeNode;
resultCode = GeneticProgramming.TypeRestrictedOperator.EnumResult.FAILED;
groupsTreeNode = new Datastructures.TreeNode();
result = new Datastructures.Variadic(Datastructures.Variadic.EnumType.STORAGEALGORITHMICCONCEPTTREE);
result.valueTree = groupsTreeNode;
// initialize groups
groups = new List<Vector2<float>>[cachedGroupArraySize.x * cachedGroupArraySize.y];
for( i = 0; i < cachedGroupArraySize.x * cachedGroupArraySize.y; i++ )
{
groups[i] = new List<Vector2<float>>();
}
if( parameters.Count < 1 || parameters[0].type != Datastructures.Variadic.EnumType.STORAGEALGORITHMICCONCEPTTREE )
{
// TODO< set error >
return;
}
// go through each point
foreach( Datastructures.TreeNode iterationPointNode in parameters[0].valueTree.childNodes )
{
Vector2<float> iterationPoint;
int groupIndex;
if( iterationPointNode.value.type != Datastructures.Variadic.EnumType.VECTOR2FLOAT )
{
// TODO< set error >
return;
}
iterationPoint = iterationPointNode.value.valueVector2Float;
groupIndex = getGroupIndexOfCoordinate(iterationPoint);
groups[groupIndex].Add(iterationPoint);
}
// build the result
for( groupI = 0; groupI < groups.Length; groupI++ )
{
Datastructures.TreeNode pointsTreeNode;
Datastructures.TreeNode outputElementTreeNode;
Vector2<float> center; // middle/average of all points
center = new Vector2<float>();
if( groups[groupI].Count == 0 )
{
continue;
}
// we are here if a element is in the group
pointsTreeNode = new Datastructures.TreeNode();
foreach( Vector2<float> iterationPoint in groups[groupI] )
{
Datastructures.TreeNode treeNodeForPoint;
treeNodeForPoint = new Datastructures.TreeNode();
treeNodeForPoint.value = new Datastructures.Variadic(Datastructures.Variadic.EnumType.VECTOR2FLOAT);
treeNodeForPoint.value.valueVector2Float = iterationPoint;
pointsTreeNode.childNodes.Add(treeNodeForPoint);
center += iterationPoint;
}
center.scale(1.0f / (float)groups[groupI].Count);
// compose tree for the group
{
Datastructures.TreeNode coordinatesTreeNode;
Datastructures.TreeNode centerTreeNode;
centerTreeNode = new Datastructures.TreeNode();
centerTreeNode.value = new Datastructures.Variadic(Datastructures.Variadic.EnumType.VECTOR2FLOAT);
centerTreeNode.value.valueVector2Float = center;
coordinatesTreeNode = new Datastructures.TreeNode();
coordinatesTreeNode.childNodes.Add(new Datastructures.TreeNode());
coordinatesTreeNode.childNodes.Add(new Datastructures.TreeNode());
coordinatesTreeNode.childNodes[0].value = new Datastructures.Variadic(Datastructures.Variadic.EnumType.INT);
coordinatesTreeNode.childNodes[1].value = new Datastructures.Variadic(Datastructures.Variadic.EnumType.INT);
coordinatesTreeNode.childNodes[0].value.valueInt = groupI % cachedGroupArraySize.x;
coordinatesTreeNode.childNodes[1].value.valueInt = groupI / cachedGroupArraySize.x;
//.........这里部分代码省略.........