当前位置: 首页>>代码示例>>C#>>正文


C# Position.GetUnitDirection方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:15,代码来源:MaxFilter.cs

示例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;
            }
        }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:39,代码来源:SteadyHandFilter.cs


注:本文中的Position.GetUnitDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。