Пример #1
0
        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);
        }
Пример #2
0
        public ConnectingMember(ElementRAZ _elementRAZ, VectorRAZ _distancevector, bool _isStartPoint, LineRAZ _idealine, double _localEccentricity)
        {
            this.ElementRAZ     = _elementRAZ;
            this.distanceVector = _distancevector;
            this.isStartPoint   = _isStartPoint;
            this.ideaLine       = _idealine;

            this.localEccentricity = _localEccentricity;
        }
Пример #3
0
        public BearingMember(ElementRAZ _elementRAZ, VectorRAZ _distancevector, bool _isStartPoint, LineRAZ _idealine, Nullable <bool> _isSingle = null)
        {
            this.ElementRAZ     = _elementRAZ;
            this.distanceVector = _distancevector;
            this.isStartPoint   = _isStartPoint;
            this.ideaLine       = _idealine;

            this.isSingle = _isSingle;
        }
Пример #4
0
        static public VectorRAZ CrossProduct(VectorRAZ a, VectorRAZ b)
        {
            double    x      = a.Y * b.Z - a.Z * b.Y;
            double    y      = a.Z * b.X - a.X * b.Z;
            double    z      = a.X * b.Y - a.Y * b.X;
            VectorRAZ vector = new VectorRAZ(x, y, z);

            return(vector);
        }
Пример #5
0
        static public double AngleBetweenVectors(VectorRAZ eerste, VectorRAZ tweede)
        {
            double ans = ((eerste.X * tweede.X) + (eerste.Y * tweede.Y) + (eerste.Z * tweede.Z)) / (eerste.length * tweede.length);
            //angle will be in most cases the smallest angle between the vectors.
            double angle = Math.Acos(ans);
            //reflexangle will be in most cases the largest angle between the vectors.
            double reflexAngle = (Math.PI * 2) - angle;

            //we only need the smallest angle between the vectors
            return(Math.Min(angle, reflexAngle));
        }
Пример #6
0
 /// <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;
 }
Пример #7
0
        /// <summary>
        /// This method rotates a the vector v arount the vector-axis n by degree degrees.
        /// </summary>
        /// <param name="n">axis to rotate around</param>
        /// <param name="degree">rotation in degrees</param>
        /// <param name="v">vector to rotate</param>
        /// <returns></returns>
        static public VectorRAZ RotateVector(VectorRAZ n, double degree, VectorRAZ v)
        {
            double rad = System.Math.PI * (degree / 180.0);

            //n should be converted to a unit-vector
            n = n.Unitize();

            //Rodrigues' rotation formula
            VectorRAZ p1 = VecScalMultiply(v, System.Math.Cos(rad));
            VectorRAZ p2 = VecScalMultiply(VecScalMultiply(n, DotProduct(v, n)), (1.0 - System.Math.Cos(rad)));
            VectorRAZ p3 = VecScalMultiply(CrossProduct(n, v), System.Math.Sin(rad));

            VectorRAZ vector = new VectorRAZ(p1.X + p2.X + p3.X, p1.Y + p2.Y + p3.Y, p1.Z + p2.Z + p3.Z);

            return(vector);
        }
Пример #8
0
        /// <summary>
        /// In this method two vectors are compared with each other. If the unitvector is equal or the inverse is equal, the method will return true.
        /// </summary>
        /// <param name="tol"></param>
        /// <param name="vectorA"></param>
        /// <param name="vectorB"></param>
        /// <returns></returns>
        static public bool AreVectorsEqual(double tol, VectorRAZ vectorA, VectorRAZ vectorB)
        {
            VectorRAZ a = vectorA.Unitize();
            VectorRAZ b = vectorB.Unitize();

            //same direction
            if (Math.Abs(a.X - b.X) < tol && Math.Abs(a.Y - b.Y) < tol && Math.Abs(a.Z - b.Z) < tol)
            {
                return(true);
            }
            //opposite direction
            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);
            }
        }
Пример #9
0
        static public VectorRAZ FlipVector(VectorRAZ vector)
        {
            VectorRAZ invers = new VectorRAZ(-vector.X, -vector.Y, -vector.Z);

            return(invers);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public static void CalculateSawingCuts(Project project, double tol)
        {
            foreach (Joint j in project.joints)
            {
                double eccentricity = new double();
                //Convert eccentricity in meter to milimeter
                //If warren double the eccentricity
                if (j.isWarrenEccentricJoint == true)
                {
                    eccentricity = 2 * j.maxGlobalEccentricity * 1000;
                }
                else
                {
                    eccentricity = j.maxGlobalEccentricity * 1000;
                }

                //phi is the angle between the bearing member and the highest ranked connecting member
                double phi = new double();
                List <AttachedMember> connectingMembers = new List <AttachedMember>();
                AttachedMember        bear = new AttachedMember();
                foreach (var con in j.attachedMembers)
                {
                    BearingMember bearing = new BearingMember();

                    if (con is BearingMember)
                    {
                        bear = con;
                    }
                    if (con is ConnectingMember)
                    {
                        connectingMembers.Add(con);
                    }
                }
                BearingMember BM = j.attachedMembers.OfType <BearingMember>().First();
                if (j.IsContinues == false)
                {
                    if (BM.isStartPoint == true)
                    {
                        BM.ElementRAZ.startCut = ElementRAZ.SawingCut.RightAngledCut;
                    }
                    else
                    {
                        BM.ElementRAZ.endCut = ElementRAZ.SawingCut.RightAngledCut;
                    }
                }

                for (int i = 0; i < connectingMembers.Count; i++)
                {
                    if (i == 0)
                    {
                        double phiDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[i].ElementRAZ.line.vector);
                        //phi should be an angle between 90 and 180 degree

                        phi = Math.PI - (Math.Min(phiDirty, (Math.PI - phiDirty)));

                        //Check if the first connecting member is a RightAngledCut or SingleMiterCut
                        //This is checked by whether theta is equal to 90 degrees (1.57 rad)
                        //phi==0 is needed for the midspan T-joint where the value of phi is lost because of some mysterious reason
                        if (Math.Abs(0.5 * Math.PI - phi) < tol || phi == 0 || phi == Math.PI)
                        {
                            //RightAngledCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.RightAngledCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.RightAngledCut;
                            }
                        }
                        else
                        {
                            //SingleMiterCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                        }
                    }
                    if (i == 1)
                    {
                        // a     = half height vertical
                        // b     = half height horizontal
                        // h     = half height diagonal
                        // theta = angle of selected connecting member to bearingmember
                        // phi   = anlge of first connecting member to bearingmember
                        // e     = eccntricity

                        double a          = connectingMembers[0].ElementRAZ.crossSection.height / 2;
                        double b          = bear.ElementRAZ.crossSection.height / 2;
                        double h          = connectingMembers[1].ElementRAZ.crossSection.height / 2;
                        double thetaDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[1].ElementRAZ.line.vector);
                        //theta should be an angle between 0 and 90 degree
                        double theta = (Math.Min(thetaDirty, Math.PI - thetaDirty));

                        double hor = ConnectingMember.WebWeldsHorizontalLength(a, b, h, theta, phi, eccentricity);
                        double ver = ConnectingMember.WebWeldsVerticalLength(a, b, h, theta, phi, eccentricity);

                        if (hor != 0.0 && ver != 0.0)
                        {
                            //DoubleMiterCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.DoubleMiterCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.DoubleMiterCut;
                            }
                        }
                        else
                        {
                            //SingleMiterCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                        }
                    }
                    if (i == 2)
                    {
                        double a          = connectingMembers[0].ElementRAZ.crossSection.height / 2;
                        double b          = bear.ElementRAZ.crossSection.height / 2;
                        double h          = connectingMembers[2].ElementRAZ.crossSection.height / 2;
                        double thetaDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[2].ElementRAZ.line.vector);
                        //theta should be an angle between 0 and 90 degree
                        double theta = (Math.Min(thetaDirty, Math.PI - thetaDirty));

                        double hor = ConnectingMember.WebWeldsHorizontalLength(a, b, h, theta, phi, eccentricity);
                        double ver = ConnectingMember.WebWeldsVerticalLength(a, b, h, theta, phi, eccentricity);

                        if (hor != 0.0 && ver != 0.0)
                        {
                            //DoubleMiterCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.DoubleMiterCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.DoubleMiterCut;
                            }
                        }
                        else
                        {
                            //SingleMiterCut
                            if (connectingMembers[i].isStartPoint == true)
                            {
                                connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                            else
                            {
                                connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut;
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
        /// <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);
            }
        }
Пример #13
0
        static public VectorRAZ VecScalMultiply(VectorRAZ vec, double scalar)
        {
            VectorRAZ vector = new VectorRAZ(vec.X * scalar, vec.Y * scalar, vec.Z * scalar);

            return(vector);
        }
Пример #14
0
        static public double DotProduct(VectorRAZ a, VectorRAZ b)
        {
            double scalar = a.X * b.X + a.Y * b.Y + a.Z * b.Z;

            return(scalar);
        }