本文整理汇总了C#中Game.Orig.Math3D.MyVector.Divide方法的典型用法代码示例。如果您正苦于以下问题:C# MyVector.Divide方法的具体用法?C# MyVector.Divide怎么用?C# MyVector.Divide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Orig.Math3D.MyVector
的用法示例。
在下文中一共展示了MyVector.Divide方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ZoomRectangle
/// <summary>
/// This function will set the center position to the center of the rectangle passed in, and set the zoom so that I can
/// see everything inside the rectangle
/// </summary>
/// <remarks>
/// I will be in static mode after this call (as opposed to chase mode)
/// </remarks>
public void ZoomRectangle(MyVector cornerLower, MyVector cornerUpper)
{
// Figure out the position. By setting it to a new vector, I've gone into static mode
_centerPoint = cornerLower + cornerUpper;
_centerPoint.Divide(2);
// Set temp X and Y to the zoom rectangle width and height
double tempX = cornerUpper.X - cornerLower.X;
double tempY = cornerUpper.Y - cornerLower.Y;
// Now set temp X and Y to the corresponding zoom factors
tempX = this.Width / tempX;
tempY = this.Height / tempY;
// Store the lower of the two
if (tempX < tempY)
{
_zoom = tempX;
}
else
{
_zoom = tempY;
}
}
示例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;
}
示例4: 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);
}
}
示例5: GetCollisionNormalAndPointsOfContact_SphereSphere
protected void GetCollisionNormalAndPointsOfContact_SphereSphere(out MyVector normal, out double normalMagnitude, out MyVector pointOfContact1, out MyVector pointOfContact2, BallBlip ball1, BallBlip ball2)
{
// Vector that is perpendicular to the tangent of the collision, and it points in the direction of object 1. Real
// easy when dealing with spheres :)
normal = ball2.Ball.Position - ball1.Ball.Position;
// Remember this length
normalMagnitude = normal.GetMagnitude();
// This needs to be returned as a unit vector
normal.Divide(normalMagnitude);
// Start them off as unit vectors
pointOfContact1 = normal.Clone();
pointOfContact2 = normal.Clone();
// Finish (use the ratio of their radii)
pointOfContact1.Multiply((ball1.Ball.Radius / (ball1.Ball.Radius + ball2.Ball.Radius)) * normalMagnitude);
pointOfContact2.Multiply((ball2.Ball.Radius / (ball1.Ball.Radius + ball2.Ball.Radius)) * normalMagnitude * -1); // I want this one pointing the other direction
// Now that I have the points of contact relative to the centers of position, I need to make them
// relative to the centers of mass
if (ball1.TorqueBall != null)
{
pointOfContact1.Subtract(ball1.TorqueBall.CenterOfMass);
}
if (ball2.TorqueBall != null)
{
pointOfContact2.Subtract(ball2.TorqueBall.CenterOfMass);
}
}