static public double LocalEccentricity(PointRAZ c, PointRAZ a, VectorRAZ dir) { double numerator = Math.Sqrt(Math.Pow((c.Y - a.Y) * dir.Z - (c.Z - a.Z) * dir.Y, 2) + Math.Pow((c.X - a.X) * dir.Z - (c.Z - a.Z) * dir.X, 2) + Math.Pow((c.X - a.X) * dir.Y - (c.Y - a.Y) * dir.X, 2)); double denumerator = Math.Sqrt(Math.Pow(dir.X, 2) + Math.Pow(dir.Y, 2) + Math.Pow(dir.Z, 2)); return(numerator / denumerator); }
public static int ShouldEccentricityBeAssumedPOSOrNEG(double tol, PointRAZ point, LineRAZ line) { if (PointRAZ.ArePointsEqual(tol, point, line.End) == true) { LineRAZ lijn2 = LineRAZ.FlipLineIfPointNotEqualStartPoint(tol, point, line); if (lijn2.vector.Z > 0) { return(-1); } else { return(1); } } else { if (line.vector.Z > 0) { return(-1); } else { return(1); } } }
public static LineRAZ TranslateLineWithVector(Project _project, LineRAZ line, VectorRAZ translation) { PointRAZ newStart = PointRAZ.CreateNewOrExisting(_project, line.Start.X + translation.X, line.Start.Y + translation.Y, line.Start.Z + translation.Z); PointRAZ newEnd = PointRAZ.CreateNewOrExisting(_project, line.End.X + translation.X, line.End.Y + translation.Y, line.End.Z + translation.Z); LineRAZ result = new LineRAZ(line.id, newStart, newEnd); return(result); }
/// <summary> /// Move line to 0,0,0 based on given point /// </summary> /// <param name="point">centerpoint of joint</param> /// <param name="line">line to move</param> /// <returns></returns> public static LineRAZ MoveLineToOrigin(PointRAZ centerpoint, LineRAZ line) { PointRAZ start = PointRAZ.MovePointToOrigin(centerpoint, line.Start); PointRAZ end = PointRAZ.MovePointToOrigin(centerpoint, line.End); LineRAZ newline = new LineRAZ(start, end); return(newline); }
/// <summary> /// 0 /// </summary> /// <param name="centerpoint">Centerpoint of Joint</param> /// <param name="point">Point that will be moved</param> /// <returns></returns> public static PointRAZ MovePointToOrigin(PointRAZ centerpoint, PointRAZ point) { double x = point.X - centerpoint.X; double y = point.Y - centerpoint.Y; double z = point.Z - centerpoint.Z; PointRAZ newpoint = new PointRAZ(x, y, z); return(newpoint); }
/// <summary> /// In this method the startpoint of the line is compared to the point. IF ther are equal the original line is returned. /// If not the line will be flipped. Where startpoint and endpoint /// </summary> /// <param name="tol"></param> /// <param name="point"></param> /// <param name="line"></param> /// <returns></returns> public static LineRAZ FlipLineIfPointNotEqualStartPoint(double tol, PointRAZ point, LineRAZ line) { if (PointRAZ.ArePointsEqual(tol, point, line.Start) == true) { return(line); } else { return(new LineRAZ(line.id, line.End, line.Start)); } }
static public bool ArePointsEqual(double tol, PointRAZ a, PointRAZ b) { if (Math.Abs(a.X - b.X) < tol && Math.Abs(a.Y - b.Y) < tol && Math.Abs(a.Z - b.Z) < tol) { return(true); } else { return(false); } }
/// <summary> /// Creates a point at specified coordinates or finds an existing point within given tolerances /// </summary> /// <param name="_project">The project the point belongs to</param> /// <param name="_x">The X coordinate of the point </param> /// <param name="_y"> The Y coordinate of the point</param> /// <param name="_z">The Z coordinate of the point</param> /// <param name="tol">Tolerance within an existing point will be returned</param> /// <returns></returns> public static PointRAZ CreateNewOrExisting(Project _project, double _x, double _y, double _z) { double tol = Project.tolerance; PointRAZ p = _project.pointRAZs.Where(a => Math.Abs(a.X - _x) <= tol && Math.Abs(a.Y - _y) <= tol && Math.Abs(a.Z - _z) <= tol).FirstOrDefault(); if (p == null) { p = new PointRAZ(_project, _x, _y, _z); } return(p); }
/// <summary> /// /// </summary> /// <param name="_project"></param> /// <param name="_id">starts from 1</param> /// <param name="_beamIDs"></param> /// <param name="_attachedMembers"></param> /// <param name="_centralNodeOfJoint"></param> /// <param name="_globaleccenticitylength">eccentricity in meters</param> /// <param name="_isWarrenEccentricJoint"></param> /// <param name="_bearingMemberUnitVector"></param> /// <param name="_IsContinues">defines wether joint is continues or ended</param> public Joint(Project _project, int _id, List <int> _beamIDs, List <AttachedMember> _attachedMembers, PointRAZ _centralNodeOfJoint, double _globaleccenticitylength, bool _isWarrenEccentricJoint, VectorRAZ _bearingMemberUnitVector, bool _IsContinues) { this.project = _project; this.id = _id; this.attachedMembers = _attachedMembers; this.beamIDs = _beamIDs; this.centralNodeOfJoint = _centralNodeOfJoint; this.maxGlobalEccentricity = _globaleccenticitylength; this.isWarrenEccentricJoint = _isWarrenEccentricJoint; this.bearingMemberUnitVector = _bearingMemberUnitVector; this.IsContinues = _IsContinues; }
public VectorRAZ(PointRAZ startpoint, PointRAZ endpoint) { this.X = endpoint.X - startpoint.X; this.Y = endpoint.Y - startpoint.Y; this.Z = endpoint.Z - startpoint.Z; }
public LineRAZ(PointRAZ _Start, PointRAZ _End) { this.Start = _Start; this.End = _End; }
public LineRAZ(int _id, PointRAZ _Start, PointRAZ _End) { this.id = _id; this.Start = _Start; this.End = _End; }
/// <summary> /// All data is inventised and converted to seperate data needed to calculate individual joints /// </summary> /// <param name="tol">tolerance</param> /// <param name="eccentricity">eccentricity if specified</param> /// <param name="points">points in project</param> /// <param name="elementRAZs">elements of project</param> /// <param name="hierarchy">hierarchy if specified</param> public void CreateJoints(double tol, double eccentricity, List <PointRAZ> points, List <ElementRAZ> elementRAZs, List <Hierarchy> hierarchy) { double tolbox = tol + eccentricity; List <Joint> joints = new List <Joint>(); //iterate over all the points that represent centerpoints of the joint for (int i = 0; i < points.Count; i++) { PointRAZ centerpoint = points[i]; List <VectorRAZ> eccentricityVectors = new List <VectorRAZ>(); List <int> elementIDs = new List <int>(); List <LineRAZ> linesatcenter = new List <LineRAZ>(); List <AttachedMember> attachedMemTemp = new List <AttachedMember>(); List <AttachedMember> attachedMembers = new List <AttachedMember>(); //1. DEFINE JOINTS //iterate over all lines in project foreach (ElementRAZ element in elementRAZs) { //STARTPoints //If fromPoints or startPoints of line fall in the tolerancebox than add lines. if (PointRAZ.ArePointsEqual(tolbox, centerpoint, element.line.Start) && element.line.vector.length > tolbox) { LineRAZ line = element.line; VectorRAZ distancevector = new VectorRAZ(0.0, 0.0, 0.0); double localEccnetricty = 0.0; ConnectingMember connectingMember = new ConnectingMember(element, distancevector, true, line, localEccnetricty); elementIDs.Add(elementRAZs.IndexOf(element)); attachedMemTemp.Add(connectingMember); } //ENDPoints //If toPoints or endPoints of line fall in the tolerancebox than add lines. if (PointRAZ.ArePointsEqual(tolbox, centerpoint, element.line.End) && element.line.vector.length > tolbox) { LineRAZ idealine = LineRAZ.FlipLine(element.line);//in this case of endpoint line needs to be flipped VectorRAZ distancevector = new VectorRAZ(0.0, 0.0, 0.0); double localEccnetricty = 0.0; ConnectingMember connectingMember = new ConnectingMember(element, distancevector, false, idealine, localEccnetricty); elementIDs.Add(elementRAZs.IndexOf(element)); attachedMemTemp.Add(connectingMember); } } //2. ORDER ATTACHEDMEMBERS ACCORDING TO HIERARCHY bool IsContinues = true; //Redistribute attachedMemTemp over BearingMember and ConnectingMember //iterate over hierarchy rank to make sure list is created in a orded way if (!hierarchy.Any()) { //no hierarchy, first member found is an ended bearing member IsContinues = false; //First member is bearing AttachedMember w = attachedMemTemp.First(); BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); //Rest of members are connecting members for (int b = 1; b < attachedMemTemp.Count; b++) { attachedMembers.Add(attachedMemTemp[b]); } } else { //hierarchy determined, list will be build based on hierarchy //TODE add code //If only one hierarchy entry defined if (hierarchy.Count == 1) { IsContinues = false; //First member is bearing AttachedMember w = attachedMemTemp.First(); BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); //Rest of members are connecting members for (int b = 1; b < attachedMemTemp.Count; b++) { attachedMembers.Add(attachedMemTemp[b]); } } else { for (int rank = 0; rank < 1 + hierarchy.Max(a => a.numberInHierarchy); rank++) { //iterate over attachedMembers of every joint //List<AttachedMember> templist = new List<AttachedMember>(); for (int ibb = 0; ibb < attachedMemTemp.Count; ibb++) { AttachedMember w = attachedMemTemp[ibb]; //if hierarchy if the highest occuring if (w.ElementRAZ.numberInHierarchy == rank && rank == attachedMemTemp.Min(a => a.ElementRAZ.numberInHierarchy)) { BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); } if (w.ElementRAZ.numberInHierarchy == rank && rank != attachedMemTemp.Min(a => a.ElementRAZ.numberInHierarchy)) { attachedMembers.Add(w); //temp //templist.Add(attachedMemTemp[ibb]); } } } } //If there is more than one Bearing Member, IsContinues joint List <BearingMember> BM = attachedMembers.OfType <BearingMember>().ToList(); if (BM.Count == 1) { IsContinues = false; } } //3. ADD JOINTS TO PROJECT //CREATE JOINT ADD TO PROJECT //Joint id starts from one, because IDEA counts from one double maxGlobalEccentricity = 0.0; bool WEJ = false; VectorRAZ bearingMemberUnitVector = new VectorRAZ(1.0, 0.0, 0.0); Joint joint = new Joint(this, i + 1, elementIDs, attachedMembers, centerpoint, maxGlobalEccentricity, WEJ, bearingMemberUnitVector, IsContinues); this.joints.Add(joint); } }