/// <summary> /// Return elbow centre point. /// Return null if the start and end points /// and direction vectors are not all coplanar. /// </summary> XYZ GetElbowCentre(Element e) { XYZ pc = null; List <Connector> cons = GetElbowConnectors(e); if (null != cons) { // Get start and end point and direction XYZ ps = cons[0].CoordinateSystem.Origin; XYZ vs = cons[0].CoordinateSystem.BasisZ; XYZ pe = cons[1].CoordinateSystem.Origin; XYZ ve = cons[1].CoordinateSystem.BasisZ; XYZ vd = pe - ps; // For a regular elbow, Z vector is normal // of the 2D plane spanned by the coplanar // start and end points and direction vectors. XYZ vz = vs.CrossProduct(vd); if (!vz.IsZeroLength()) { XYZ vxs = vs.CrossProduct(vz); XYZ vxe = ve.CrossProduct(vz); pc = Util.LineLineIntersection( ps, vxs, pe, vxe); } } return(pc); }