本文整理汇总了C#中Side.setRealLength方法的典型用法代码示例。如果您正苦于以下问题:C# Side.setRealLength方法的具体用法?C# Side.setRealLength怎么用?C# Side.setRealLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Side
的用法示例。
在下文中一共展示了Side.setRealLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addSide
public Side addSide(string idStart, string idEnd, int length)
{
if (idStart.Equals(idEnd))
return null;
Side side = new Side(idStart, idEnd);
Node a = getNodeForId(idStart);
Node b = getNodeForId(idEnd);
if (a != null && b != null)
{
int x = a.getX() - b.getX();
int y = a.getY() - b.getY();
if (length == -1)
side.setLenght((float) Mathf.Sqrt(x*x + y*y));
else
side.setLenght(length);
side.setRealLength((float) Mathf.Sqrt(x*x + y*y));
}
if (sides.Contains(side))
{
return null;
}
else
{
sides.Add(side);
}
return side;
}
示例2: Clone
public object Clone()
{
Trajectory t = (Trajectory) this.MemberwiseClone();
Dictionary<string, string> keyRelationship = new Dictionary<string, string>();
string initialId = initial.getID();
t.initial = (initial != null ? (Node) initial.Clone() : null);
keyRelationship.Add(initialId, t.initial.getID());
if (nodes != null)
{
t.nodes = new List<Node>();
foreach (Node n in nodes)
{
if (n.getID().Equals(initialId))
t.nodes.Add(t.initial);
else
{
string oldId = n.getID();
//node clone generates a new Id
Node newNode = (Node) n.Clone();
t.nodes.Add(newNode);
keyRelationship.Add(oldId, newNode.getID());
}
}
}
if (sides != null)
{
t.sides = new List<Side>();
foreach (Side s in sides)
{
//Side clone does not generate a new Id
Side newSide = new Side(keyRelationship[s.getIDStart()], keyRelationship[s.getIDEnd()]);
newSide.setLenght(s.getLength());
newSide.setRealLength(s.getRealLength());
t.sides.Add(newSide);
}
}
return t;
}