本文整理汇总了C#中Point.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Point.IsValid方法的具体用法?C# Point.IsValid怎么用?C# Point.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.IsValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLine
/// <param name="angleRadians">The angle, in radians, from 3-o'clock going counter-clockwise.</param>
public static void DrawLine(this DrawingContext drawingContext, Pen pen, Point startPoint, double angleRadians, double length)
{
Contract.Requires<ArgumentNullException>(drawingContext != null);
Contract.Requires<ArgumentException>(startPoint.IsValid());
Contract.Requires<ArgumentNullException>(pen != null);
drawingContext.DrawLine(pen, startPoint, startPoint + GeoHelper.GetVectorFromAngle(angleRadians, length));
}
示例2: DrawLine
/// <param name="angleRadians">The angle, in radians, from 3-o'clock going counter-clockwise.</param>
public static void DrawLine(this DrawingContext drawingContext, Pen pen, Point startPoint, double angleRadians, double length)
{
Util.RequireNotNull(drawingContext, "drawingContext");
Util.RequireArgument(startPoint.IsValid(), "startPoint");
Util.RequireNotNull(pen, "Pen");
drawingContext.DrawLine(pen, startPoint, startPoint + GeoHelper.GetVectorFromAngle(angleRadians, length));
}
示例3: AngleRad
public static double AngleRad(Point point1, Point point2, Point point3)
{
Debug.Assert(point1.IsValid());
Debug.Assert(point2.IsValid());
Debug.Assert(point3.IsValid());
double rad = AngleRad(point2.Subtract(point1), point2.Subtract(point3));
double rad2 = AngleRad(point2.Subtract(point1), (point2.Subtract(point3)).RightAngle());
if (rad2 < (Math.PI / 2))
{
return rad;
}
else
{
return (Math.PI * 2) - rad;
}
}
示例4: Subtract
public static Vector Subtract(this Point point, Point other)
{
Contract.Requires(point.IsValid());
Contract.Requires(other.IsValid());
Contract.Ensures(Contract.Result<Vector>().IsValid());
return new Vector(point.X - other.X, point.Y - other.Y);
}
示例5: 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.IsValid());
Debug.Assert(currentVelocity.IsValid());
Debug.Assert(targetValue.IsValid());
Debug.Assert(dampening.IsValid());
Debug.Assert(dampening > 0 && dampening < 1);
Debug.Assert(attractionFator.IsValid());
Debug.Assert(attractionFator > 0);
Debug.Assert(terminalVelocity > 0);
Debug.Assert(minValueDelta > 0);
Debug.Assert(minVelocityDelta > 0);
Vector diff = targetValue.Subtract(currentValue);
if (diff.Length > minValueDelta || currentVelocity.Length > minVelocityDelta)
{
newVelocity = currentVelocity * (1 - dampening);
newVelocity += diff * attractionFator;
if (currentVelocity.Length > terminalVelocity)
{
newVelocity *= terminalVelocity / currentVelocity.Length;
}
newValue = currentValue + newVelocity;
return true;
}
else
{
newValue = targetValue;
newVelocity = new Vector();
return false;
}
}
示例6: GetCurrentValueCore
/// <summary/>
protected override Point GetCurrentValueCore(Point baseFromValue, Point baseToValue, AnimationClock animationClock) {
var progress = animationClock.CurrentProgress;
if (!progress.HasValue || Interpolator == null) {
return base.GetCurrentValueCore(baseFromValue, baseToValue, animationClock);
}
var fromValue = new Point();
var toValue = new Point();
var offset = new Vector();
var isValid = true;
if (From.HasValue) {
fromValue = From.Value;
if (To.HasValue) {
// from ... to
toValue = To.Value;
if (IsAdditive) {
offset = (Vector)baseFromValue;
isValid = offset.IsValid();
}
} else if (By.HasValue) {
// from ... from+by
toValue = fromValue + (Vector)By.Value;
if (IsAdditive) {
offset = (Vector)baseFromValue;
isValid = offset.IsValid();
}
} else {
// from ... base
toValue = baseToValue;
isValid = toValue.IsValid();
}
} else if (To.HasValue) {
// base ... to
fromValue = baseFromValue;
toValue = To.Value;
isValid = fromValue.IsValid();
} else if (By.HasValue) {
// base ... base+by
toValue = By.Value;
offset = (Vector)baseFromValue;
isValid = offset.IsValid();
} else {
// base ... base
fromValue = baseFromValue;
toValue = baseToValue;
isValid = fromValue.IsValid() && toValue.IsValid();
}
if (!isValid) {
throw new InvalidOperationException("GetCurrentValueCore");
}
if (IsCumulative) {
var iteration = animationClock.CurrentIteration;
if (iteration.HasValue && iteration.Value > 1) {
offset += (toValue - fromValue) * (iteration.Value - 1);
}
}
var interpolator = Interpolator ?? Interpolators.Linear;
return fromValue + (toValue - fromValue) * interpolator(progress.Value, 0.0, 1.0) + offset;
}