using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Serein.Workbench.Extension
{
///
/// 点(Point)和向量(Vector)的扩展方法
///
public static class PointExtension
{
///
/// 将两个点相加,返回一个新的点。
///
///
///
///
public static Point Add(this Point a, Point b)
{
return new Point(a.X + b.X, a.Y + b.Y);
}
///
/// 将两个点相减,返回一个新的点。
///
///
///
///
public static Point Sub(this Point a, Point b)
{
return new Point(a.X - b.X, a.Y - b.Y);
}
///
/// 将点转换为向量。
///
///
///
public static Vector ToVector(this Point me)
{
return new Vector(me.X, me.Y);
}
}
///
/// 向量(Vector)的扩展方法
///
public static class VectorExtension
{
///
/// 计算两个向量的点积。
///
///
///
///
public static double DotProduct(this Vector a, Vector b)
{
return a.X * b.X + a.Y * b.Y;
}
///
/// 计算两个向量的叉积。
///
///
///
public static Vector NormalizeTo(this Vector v)
{
var temp = v;
temp.Normalize();
return temp;
}
}
}