本文整理汇总了C#中Segment.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.Rotate方法的具体用法?C# Segment.Rotate怎么用?C# Segment.Rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.Rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collide
public bool collide()
{
// Retrieve the environment singleton
Environment env = Environment.Instance;
// Create the initial segment for the angle and starting point of the bumper
double a = angle / nbsegments;
Segment vector = new Segment(env.AgentPosition, env.AgentPosition + new Point(-radius, 0));
vector = vector.Rotate(-(180 - angle) / 2);
vector = vector.Rotate(env.AgentAngle);
// Create the bumper segments
for (int i = 0; i < nbsegments; i++)
{
Segment seg = new Segment();
seg.Start = vector.End;
vector = vector.Rotate(-a);
seg.End = vector.End;
segments[i] = seg;
}
// Check if any of the segment collides
lock (env.Segments)
{
foreach (Segment s in env.Segments)
{
foreach (Segment b in segments)
{
if (b.Intersects(s) != null)
return true;
}
}
}
return false;
}
示例2: straight
public void straight(int speed)
{
// Retrieve the environment singleton
Environment env = Environment.Instance;
// Calculate the next position
Segment nextPos = new Segment();
nextPos.Start.X = env.AgentPosition.X;
nextPos.Start.Y = env.AgentPosition.Y;
nextPos.End.X = env.AgentPosition.X;
nextPos.End.Y = env.AgentPosition.Y + 1;
nextPos = nextPos.Rotate(env.AgentAngle);
env.AgentPosition = nextPos.End;
// Sleep to give the speed limitation behaviour
if (env.SimulationSpeed != 0)
System.Threading.Thread.Sleep((int)(1000 / (speed * env.SimulationSpeed)));
}
示例3: getDistance
public double getDistance()
{
// Retrieve the environment
Environment env = Environment.Instance;
double minDistance = -1;
// Create the offset segment
Segment offset = new Segment();
offset.Start = env.AgentPosition;
offset.End = env.AgentPosition + new Point(0, lengthOffset);
// Create the range segment
Segment full = new Segment();
full.Start = env.AgentPosition;
full.End = env.AgentPosition + new Point(0, length + lengthOffset);
range = new Segment();
range.Start = offset.Rotate(env.AgentAngle + angleOffset).End;
range.End = full.Rotate(env.AgentAngle + angleOffset).End;
// Go through the list of segments, not neat O(n) but execution
// fast enough for this simulation purpose
foreach (Segment s in env.Segments)
{
Point p;
if ((p = range.Intersects(s)) != null)
{
double v = p.Distance(range.Start);
if (v < minDistance || minDistance == -1)
{
minDistance = v;
}
}
}
return minDistance;
}