本文整理汇总了C#中Position.GetUnitDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Position.GetUnitDirection方法的具体用法?C# Position.GetUnitDirection怎么用?C# Position.GetUnitDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position.GetUnitDirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVelocity
public override PointD GetVelocity(Position.IVirtualMousePosition m)
{
// velocity restriction
double speed = m.GetSpeed();
double speedLimit = m_Param.C * 10 * GetStrength(m.GetVirtualPointD());
if (speed > speedLimit)
{
PointD maxParts = new PointD(speedLimit * m.GetUnitDirection().X, speedLimit * m.GetUnitDirection().Y);
return -1 * m.GetVelocity() + maxParts;
}
else
{
return PointD.Empty;
}
}
示例2: GetVelocity
public override PointD GetVelocity(Position.IVirtualMousePosition m)
{
PointD direction = m.GetUnitDirection();
if (direction.Magnitude() > 0.1)
{
m_direction = direction * 0.1 + m_direction * 0.9; // mixture of previous and current input
}
if (m_direction.Magnitude() > Render.DrawHelper.MIN_SPEED_SENSITIVITY)
{
m_direction = m_direction / m_direction.Magnitude(); // unit vector
m_Param.V = m_direction; // direction stored internally, but exposed
PointD velParallel;
// prevent motion retracing the path (going in opposite direction)
if (PointD.DotProduct(m_direction, m.GetVelocity()) > 0)
{
velParallel = PointD.DotProduct(m_direction, m.GetVelocity()) * m_direction;
}
else
{
// curving opposite motion slightly until more direction events received
// (how much velocity to go backwards)
velParallel = PointD.DotProduct(m_direction, m.GetVelocity()) * -(1 - m_Param.C) * m_direction;
//m_direction = -0.5 * m_direction;
//velParallel = PointD.DotProduct(m_direction, m.GetVelocity()) * m_direction;// PointD.DotProduct(m_direction, m.GetVelocity()) * -(1 - m_Param.C) * m_direction;
}
PointD origVelocityTangent = PointD.DotProduct(m_direction, m.GetVelocity()) * m_direction;
PointD origVelocityNormal = PointD.DotProduct(PointD.Orthogonal(m_direction), m.GetVelocity()) * PointD.Orthogonal(m_direction);
// first cancel out the original velocity, then put the new one in
return -1 * origVelocityTangent + -m_Param.C * origVelocityNormal + velParallel;
}
else
{
return PointD.Empty;
}
}