本文整理汇总了C#中System.Windows.Vector.IsRational方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.IsRational方法的具体用法?C# Vector.IsRational怎么用?C# Vector.IsRational使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Vector
的用法示例。
在下文中一共展示了Vector.IsRational方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dot
public static double Dot(Vector v1, Vector v2)
{
Debug.Assert(v1.IsRational());
Debug.Assert(v2.IsRational());
return v1.X * v2.X + v1.Y * v2.Y;
}
示例2: Animate
public static bool Animate(
Point currentValue, Vector currentVelocity, Point targetValue,
double attractionFator, double dampening,
double terminalVelocity, double minValueDelta, double minVelocityDelta,
out Point newValue, out Vector newVelocity)
{
Debug.Assert(currentValue.IsRational());
Debug.Assert(currentVelocity.IsRational());
Debug.Assert(targetValue.IsRational());
Debug.Assert(dampening.IsRational());
Debug.Assert(dampening > 0 && dampening < 1);
Debug.Assert(attractionFator.IsRational());
Debug.Assert(attractionFator > 0);
Debug.Assert(terminalVelocity > 0);
Debug.Assert(minValueDelta > 0);
Debug.Assert(minVelocityDelta > 0);
Vector diff = targetValue - currentValue;
if (diff.Length > minValueDelta || currentVelocity.Length > minVelocityDelta)
{
newVelocity = currentVelocity * (1 - dampening);
newVelocity += diff * attractionFator;
newVelocity *= (currentVelocity.Length > terminalVelocity) ? terminalVelocity / currentVelocity.Length : 1;
newValue = currentValue + newVelocity;
return true;
}
else
{
newValue = targetValue;
newVelocity = new Vector();
return false;
}
}
示例3: AngleRad
public static double AngleRad(Vector v1, Vector v2)
{
Debug.Assert(v1.IsRational());
Debug.Assert(v2.IsRational());
double dot = Dot(v1, v2);
double dotNormalize = dot / (v1.Length * v2.Length);
double acos = Math.Acos(dotNormalize);
return acos;
}