本文整理汇总了C#中Vector2d.Negate方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2d.Negate方法的具体用法?C# Vector2d.Negate怎么用?C# Vector2d.Negate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2d
的用法示例。
在下文中一共展示了Vector2d.Negate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Loop
public void Loop(TimeSpan loopTime)
{
foreach (var connection in Graph.Connectivities)
{
var node1 = connection.Node1;
var node2 = connection.Node2;
var distance = Vector2d.GetDistance(node1.Position, node2.Position);
if (distance < 0.1)
{
// Jitter
distance = 0.1;
}
var forceS = Settings.DistanceToForceFct(distance);
forceS *= Settings.ForceFactor;
forceS *= connection.Connectivity;
var dX = Math.Max(0.1, node1.Position.X - node2.Position.X);
var dY = Math.Max(0.1, node1.Position.Y - node2.Position.Y);
Vector2d force = new Vector2d(forceS * dX / distance, forceS * dY / distance);
node1.ForceN.AddTo(force.Negate());
node2.ForceN.AddTo(force);
}
}
示例2: Loop
public void Loop(TimeSpan loopTime)
{
var random = new Random();
var nodeCount = graph.Nodes.Count;
for (var n = 0; n < (nodeCount - 1); n++)
{
for (var m = n + 1; m < nodeCount; m++)
{
var node1 = graph.Nodes[n];
var node2 = graph.Nodes[m];
var distance = Vector2d.GetDistance(node1.Position, node2.Position);
if (distance < Settings.MinimumDistance)
{
var forceS = (distance - Settings.MinimumDistance) / Settings.MinimumDistance;
var dX = node1.Position.X - node2.Position.X;
var dY = node1.Position.Y - node2.Position.Y;
if ( distance < 0.01)
{
dX = (random.NextDouble() - 0.5) * 2;
dY = Math.Sqrt(1 - dX * dX);
}
else
{
dX /= distance;
dY /= distance;
}
Vector2d force = new Vector2d(forceS * dX, forceS * dY);
node1.ForceN.AddTo(force.Negate());
node2.ForceN.AddTo(force);
}
}
}
}