using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; namespace KDCS.UtilsGe { public class Vector { private const double CrossingTolerance = 0.031; public XYZ Start { get; set; } public XYZ End { get; set; } public XYZ Instance { get; set; } public double Length { get; set; } public Line BoundLine { get; set; } public Vector(XYZ start, XYZ end, bool bZ0 = false) { if (bZ0) { Start = new XYZ(start.X, start.Y, 0.0); End = new XYZ(end.X, end.Y, 0.0); } else { Start = start; End = end; } Instance = End - Start; Length = Instance.GetLength(); BoundLine = Line.CreateBound(Start, End); } public Vector(Curve curve, bool bZ0 = false) { XYZ start = curve.GetEndPoint(0); XYZ end = curve.GetEndPoint(1); if (bZ0) { Start = new XYZ(start.X, start.Y, 0.0); End = new XYZ(end.X, end.Y, 0.0); } else { Start = start; End = end; } Instance = End - Start; Length = Instance.GetLength(); } public XYZ Intersect(Vector vector) { Line line1 = Line.CreateBound(vector.Start, vector.End); IntersectionResultArray intResultArray; BoundLine.Intersect(line1, out intResultArray); if (intResultArray != null) { if (intResultArray.Size > 0) { IntersectionResult ir = intResultArray.get_Item(0); if (ir.XYZPoint != null) return ir.XYZPoint; } } return null; } public bool IsOnVector(XYZ point, bool checkHeight = false) { return (Math.Abs((Start.DistanceTo(point) + End.DistanceTo(point)) - this.Length) <= 0.0001); // 1mm = 0.003281 ft(피트) } } }