using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GraphicsStudy
{
public static class VectorsMethod
{
///
/// 向量是否平行
///
///
///
/// true为同向平行,false为反向平行,null为平行
/// 允许误差的角度
///
public static bool IsParallel(this XYZ vector1, XYZ vector2, bool? v = null, double tolerance = 0.1)
{
if (v == null)
{
return vector1.AngleTo(vector2) > (180 - tolerance).ToRad() || vector1.DistanceTo(vector2) < tolerance.ToRad();
}
else if (v == true)
{
return vector1.AngleTo(vector2) < tolerance.ToRad();
}
else
{
return vector1.AngleTo(vector2) > (180 - tolerance).ToRad();
}
}
}
}