本文整理汇总了C#中Game.Orig.Math3D.MyVector.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MyVector.Add方法的具体用法?C# MyVector.Add怎么用?C# MyVector.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Orig.Math3D.MyVector
的用法示例。
在下文中一共展示了MyVector.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, EventArgs e)
{
MyVector v1 = new MyVector(3, 4, 5);
v1.Add(1, 2, 3);
v1.BecomeUnitVector();
MyVector v2 = v1.Clone();
v2.Multiply(3);
v1.Divide(3);
}
示例2: Copy
private void Copy()
{
if (_mode != SelectionMode.Selected || _selectedObjects.Count == 0)
{
return;
}
_myClipboard.Clear();
_clipboardPositionCenter = new MyVector();
foreach (RadarBlip blip in _map.GetAllBlips())
{
if (_selectedObjects.Contains(blip.Token))
{
_myClipboard.Add(Scenes.CloneBlip(blip, _map));
_clipboardPositionCenter.Add(blip.Sphere.Position);
}
}
if (_myClipboard.Count > 0)
{
_clipboardPositionCenter.Divide(_myClipboard.Count);
}
}
示例3: TimerSprtCalculateVelocity
/// <summary>
/// This function prunes the list of positions that are too old. It then figures out the average velocity
/// of the remaining positions.
/// </summary>
private MyVector TimerSprtCalculateVelocity()
{
const int RETENTION = 75; // milliseconds
int curTick = Environment.TickCount;
// Add the current to the list
_prevMousePositions.Add(new MousePosition(_curMousePoint.Clone()));
#region Prune List
int lastIndex = -1;
for (int cntr = _prevMousePositions.Count - 1; cntr >= 0; cntr--)
{
if (curTick - _prevMousePositions[cntr].Tick > RETENTION)
{
// This item is too old. And since the list is in time order, all the entries before this are also too old
lastIndex = cntr;
break;
}
}
if (lastIndex >= 0)
{
//_prevMousePositions.RemoveRange(lastIndex, _prevMousePositions.Count - lastIndex);
_prevMousePositions.RemoveRange(0, lastIndex + 1);
}
#endregion
#region Calculate Velocity
MyVector retVal = new MyVector(0, 0, 0);
// Add up all the instantaneous velocities
for (int cntr = 0; cntr < _prevMousePositions.Count - 1; cntr++)
{
retVal.Add(_prevMousePositions[cntr + 1].Position - _prevMousePositions[cntr].Position);
}
// Take the average
if (_prevMousePositions.Count > 2) // if count is 0 or 1, then retVal will still be (0,0,0). If it's 2, then I would be dividing by 1, which is pointless
{
retVal.Divide(_prevMousePositions.Count - 1);
}
#endregion
// Exit Function
return retVal;
}