public void SetLCS(AttachedMember attachedMember, LineSegment3D lineSegment) { //Defining LCS for First lineSegment double xcor = attachedMember.ElementRAZ.line.vector.X; double ycor = attachedMember.ElementRAZ.line.vector.Y; double zcor = attachedMember.ElementRAZ.line.vector.Z; //Define LCS (local-y in XY plane) and unitize VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize(); VectorRAZ vy = new VectorRAZ(); VectorRAZ vz = new VectorRAZ(); if (xcor == 0.0 && ycor == 0.0) { vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize(); vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize(); } else { vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize(); vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize(); } if (attachedMember.ElementRAZ.rotationLCS == 0.0) { } else { vy = VectorRAZ.RotateVector(vx, attachedMember.ElementRAZ.rotationLCS, vy); vz = VectorRAZ.RotateVector(vx, attachedMember.ElementRAZ.rotationLCS, vz); } var LocalCoordinateSystem = new CoordSystemByVector(); LocalCoordinateSystem.VecX = new Vector3D() { X = vx.X, Y = vx.Y, Z = vx.Z }; LocalCoordinateSystem.VecY = new Vector3D() { X = vy.X, Y = vy.Y, Z = vy.Z }; LocalCoordinateSystem.VecZ = new Vector3D() { X = vz.X, Y = vz.Y, Z = vz.Z }; lineSegment.LocalCoordinateSystem = LocalCoordinateSystem; }
public void SetLCSwithRotation(AttachedMember attachedMember, LineSegment3D lineSegment) { //Explode x-vector double xcor = attachedMember.ElementRAZ.line.vector.X; double ycor = attachedMember.ElementRAZ.line.vector.Y; double zcor = attachedMember.ElementRAZ.line.vector.Z; VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize(); double rotation = attachedMember.ElementRAZ.rotationLCS; //Explode z-vector double xcorZ = 0.0; double ycorZ = 0.0; double zcorZ = 0.0; VectorRAZ vz = new VectorRAZ(xcorZ, ycorZ, zcorZ).Unitize(); //Create y-vector with cross-product VectorRAZ vy = new VectorRAZ(); vz = new VectorRAZ((vz.Y * vx.Z - vx.Y * vz.Z), (-vz.X * vx.Z + vx.X * vz.Z), (vz.X * vx.Y - vx.X * vz.Y)).Unitize(); //Set LCS var LocalCoordinateSystem = new CoordSystemByVector(); LocalCoordinateSystem.VecX = new Vector3D() { X = vx.X, Y = vx.Y, Z = vx.Z }; LocalCoordinateSystem.VecY = new Vector3D() { X = vy.X, Y = vy.Y, Z = vy.Z }; LocalCoordinateSystem.VecZ = new Vector3D() { X = vz.X, Y = vz.Y, Z = vz.Z }; lineSegment.LocalCoordinateSystem = LocalCoordinateSystem; }
static void Main() { VectorRAZ a = new VectorRAZ(1, 2, 3); VectorRAZ b = new VectorRAZ(0, 0, 1); double angle = 90.0; double scalar = VectorRAZ.DotProduct(a, b); VectorRAZ vector = VectorRAZ.CrossProduct(a, b); VectorRAZ xx = VectorRAZ.RotateVector(b, angle, a); System.Windows.Media.Media3D.Vector3D va = new System.Windows.Media.Media3D.Vector3D(a.X, a.Y, a.Z); System.Windows.Media.Media3D.Vector3D vb = new System.Windows.Media.Media3D.Vector3D(b.X, b.Y, b.Z); double dot = System.Windows.Media.Media3D.Vector3D.DotProduct(va, vb); System.Windows.Media.Media3D.Vector3D cross = System.Windows.Media.Media3D.Vector3D.CrossProduct(va, vb); System.Windows.Media.Media3D.AxisAngleRotation3D vec = new System.Windows.Media.Media3D.AxisAngleRotation3D(); //System.Windows.Media.Media3D.Rotation3D rot = new System.Windows.Media.Media3D.Rotation3D(); KarambaIDEA.MainWindow mainWindow = new MainWindow(); Tester.GenerateTestJoint fj = new GenerateTestJoint(); //KarambaIDEA.TestFrameworkJoint fj = new TestFrameworkJoint(); //hieronder testjoint definieren Joint joint = fj.Testjoint(); //Joint joint = fj.Testjoint5(); joint.project.CreateFolder(@"C:\Data\"); joint.project.templatePath = @"C:\Data\template.contemp"; //min lasafmeting uitzetten bij Grasshopper joint.project.minthroat = 1.0; mainWindow.Test(joint); }
private void CreateIDEAOpenModelResultsOLD(Joint joint) { Project project = joint.project; openModelResult.ResultOnMembers = new List <ResultOnMembers>(); ResultOnMembers resultIF = new ResultOnMembers(); for (int ibeam = 0; ibeam < openModel.Member1D.Count; ibeam++) { //Continues Chord consist out of one member Member1D mb = openModel.Member1D[ibeam]; for (int iele = 0; iele < mb.Elements1D.Count; iele++) { //Continues chord consist out of two elements Element1D elem = openModel.Element1D.First(a => a.Id == mb.Elements1D[iele].Id); //results on members are constant in the framework ResultOnMember resMember = new ResultOnMember(new Member() { Id = elem.Id, MemberType = MemberType.Element1D }, ResultType.InternalForces); int numPoints = 10; for (int ip = 0; ip <= numPoints; ip++) { ResultOnSection resSec = new ResultOnSection(); resSec.AbsoluteRelative = AbsoluteRelative.Relative; resSec.Position = (double)ip / (double)numPoints; //iterate over loadcases int count = openModel.LoadCase.Count; for (int i = 1; i <= count; i++) { ResultOfInternalForces resLoadCase = new ResultOfInternalForces(); int loadCaseNumber = i; resLoadCase.Loading = new ResultOfLoading() { Id = loadCaseNumber, LoadingType = LoadingType.LoadCase }; resLoadCase.Loading.Items.Add(new ResultOfLoadingItem() { Coefficient = 1.0 }); //Check if Startpoint is equal to centerpoint int GrassId = elem.Id - 1;//Element1D.Id - 1 == ElementRAZ.id int GrassLCId = i - 1; AttachedMember attached = joint.attachedMembers.Find(a => a.ElementRAZ.id == GrassId); //The following if statements simulate that every member has a local coordinate system //where the local z - axis points counterclockwise(shear force) //and where the positive bending moment is clockwise if (attached.isStartPoint == true) { //Pick startloads // API to IDEA UI, My and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.N; double My0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.My * -1; double Vz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vz * -1; double Vy0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].startLoads.Mt; //From Karamba3D to Framework double N = N0; double My = My0; double Vz = Vz0; double Vy = Vy0; double Mz = Mz0; double Mt = Mt0; //From Framework to IDEA VectorRAZ unitvector = attached.ideaLine.vector.Unitize();//gaat niet op bij ColumnT-Joint want gebruikt globale asses ipv locale if (unitvector.X < -10e-6) { if (attached is BearingMember) //exception { resLoadCase.N = N; // resLoadCase.My = My * (-1); // in case of start point M of the begin element of the chords needs to be flipped resLoadCase.Qz = Vz * (-1); // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } else//members where rule needs to be applied to { resLoadCase.N = N;// resLoadCase.My = My * -1; // resLoadCase.Qz = Vz * -1; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } else { resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } else//isEndPoint { //Pick endloads //API to IDEA UI, My and Vz are plotted negatively double N0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.N; double My0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.My * -1; double Vz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vz * -1; double Vy0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Vy; double Mz0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mz; double Mt0 = 1000 * joint.project.loadcases[GrassLCId].loadsPerLineRAZs[GrassId].endLoads.Mt; //From Karamba3D to Framework double N = N0; double My = My0 * (-1); //*-1 double Vz = Vz0 * (-1); //*-1 double Vy = Vy0 * (-1); //*-1 double Mz = Mz0 * (-1); //*-1 double Mt = Mt0 * (-1); //*-1 //From Framework to IDEA VectorRAZ unitvector = attached.ideaLine.vector.Unitize();//gaat niet op bij ColumnT-Joint want gebruikt globale asses ipv locale if (unitvector.X < -10e-6) { if (attached is BearingMember) //exception { resLoadCase.N = N; // resLoadCase.My = My * (-1); // in case of start point M of the begin element of the chords needs to be flipped resLoadCase.Qz = Vz * (-1); // resLoadCase.Qy = Vy * (-1); resLoadCase.Mz = Mz0 * (-1); resLoadCase.Mx = Mt * (-1); resSec.Results.Add(resLoadCase); } else//members where rule needs to be applied to { resLoadCase.N = N;// resLoadCase.My = My * (-1); // * (-1) resLoadCase.Qz = Vz * (-1); // * (-1) resLoadCase.Qy = Vy * (-1); resLoadCase.Mz = Mz0 * (-1); resLoadCase.Mx = Mt * (-1); resSec.Results.Add(resLoadCase); } } else { resLoadCase.N = N; // resLoadCase.My = My; // resLoadCase.Qz = Vz; // resLoadCase.Qy = Vy; resLoadCase.Mz = Mz0; resLoadCase.Mx = Mt; resSec.Results.Add(resLoadCase); } } } resMember.Results.Add(resSec); } resultIF.Members.Add(resMember); } } openModelResult.ResultOnMembers.Add(resultIF); }
private void AddConnectedMember(AttachedMember attachedMember, ConnectionPoint connectionPoint) { PolyLine3D polyLine3D = new PolyLine3D(); polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1; openModel.AddObject(polyLine3D); //endpoints Point3D pA = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.Start.id); Point3D pB = openModel.Point3D.First(a => a.Id == attachedMember.ideaLine.End.id); //create line segment LineSegment3D lineSegment = new LineSegment3D(); lineSegment.Id = openModel.GetMaxId(lineSegment) + 1; lineSegment.StartPoint = new ReferenceElement(pA); lineSegment.EndPoint = new ReferenceElement(pB); openModel.AddObject(lineSegment); polyLine3D.Segments.Add(new ReferenceElement(lineSegment)); ///* double xcor = attachedMember.ElementRAZ.line.vector.X; double ycor = attachedMember.ElementRAZ.line.vector.Y; double zcor = attachedMember.ElementRAZ.line.vector.Z; //Define LCS (local-y in XY plane) and unitize VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize(); VectorRAZ vy = new VectorRAZ(); VectorRAZ vz = new VectorRAZ(); if (xcor == 0.0 && ycor == 0.0) { vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize(); vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize(); } else { vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize(); vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize(); } var LocalCoordinateSystem = new CoordSystemByVector(); LocalCoordinateSystem.VecX = new Vector3D() { X = vx.X, Y = vx.Y, Z = vx.Z }; LocalCoordinateSystem.VecY = new Vector3D() { X = vy.X, Y = vy.Y, Z = vy.Z }; LocalCoordinateSystem.VecZ = new Vector3D() { X = vz.X, Y = vz.Y, Z = vz.Z }; lineSegment.LocalCoordinateSystem = LocalCoordinateSystem; //*/ //create element Element1D element1D = new Element1D(); //element1D.Id = openModel.GetMaxId(element1D) + 1; element1D.Id = attachedMember.ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One element1D.Name = "Element " + element1D.Id.ToString(); element1D.Segment = new ReferenceElement(lineSegment); IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == attachedMember.ElementRAZ.crossSection.id); element1D.CrossSectionBegin = new ReferenceElement(crossSection); element1D.CrossSectionEnd = new ReferenceElement(crossSection); if (attachedMember is ConnectingMember) { ConnectingMember connectingMember = attachedMember as ConnectingMember; double eccentricty = new double(); if (connectingMember.localEccentricity == -0) { eccentricty = 0; } else { eccentricty = connectingMember.localEccentricity; } element1D.EccentricityBeginZ = eccentricty; element1D.EccentricityEndZ = eccentricty; } openModel.AddObject(element1D); //create member Member1D member1D = new Member1D(); member1D.Id = openModel.GetMaxId(member1D) + 1; member1D.Name = "Member " + member1D.Id.ToString(); member1D.Elements1D.Add(new ReferenceElement(element1D)); openModel.Member1D.Add(member1D); //create connected member ConnectedMember connectedMember = new ConnectedMember(); connectedMember.Id = member1D.Id; connectedMember.MemberId = new ReferenceElement(member1D); connectionPoint.ConnectedMembers.Add(connectedMember); }
private void AddConnectedMember(List <BearingMember> bearingMembers, ConnectionPoint connectionPoint) { PolyLine3D polyLine3D = new PolyLine3D(); polyLine3D.Id = openModel.GetMaxId(polyLine3D) + 1; openModel.AddObject(polyLine3D); Point3D pA = new Point3D(); Point3D pB = new Point3D(); Point3D pC = new Point3D(); Point3D pD = new Point3D(); //view from point [B], point [B] is centerpoint of connection if (bearingMembers[0].isStartPoint == false) { if (bearingMembers[1].isStartPoint == true) { // [A]=0=>[B]=1=>[C] pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id); pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id); pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id); pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id); } else { // [A]=0=>[B]<=1=[C] pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id); pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id); pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id); pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id); } } else { if (bearingMembers[1].isStartPoint == true) { // [A]<=0=[B]=1=>[C] pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id); pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id); pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id); pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id); } else { // [A]<=0=[B]<=1=[C] pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id); pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id); pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id); pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id); /* * pA = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.End.id); * pB = openModel.Point3D.First(a => a.Id == bearingMembers[1].ElementRAZ.line.Start.id); * pC = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.End.id); * pD = openModel.Point3D.First(a => a.Id == bearingMembers[0].ElementRAZ.line.Start.id); */ } } //segments /* * Point3D pA = openModel.Point3D.First(a => a.Id == bearingMembers[0].ideaLine.Start.id); * Point3D pB = openModel.Point3D.First(a => a.Id == bearingMembers[0].ideaLine.End.id); * Point3D pC = openModel.Point3D.First(a => a.Id == bearingMembers[1].ideaLine.Start.id); * Point3D pD = openModel.Point3D.First(a => a.Id == bearingMembers[1].ideaLine.End.id); */ List <Point3D> points = new List <Point3D>() { pA, pB, pC, pD }; //Point3D pointB = points.Where(a => a.Id == connectionPoint.Id).First(); //Point3D pointA = points.Where(a => a.Id != connectionPoint.Id).ToList()[0];//logica //Point3D pointC = points.Where(a => a.Id != connectionPoint.Id).ToList()[1]; //Note: not most robust solution, e.g. does not hold in case of segments with inverse vectors Point3D pointA = pA; //Endpoint of first member Point3D pointB = pB; //Startpoint of first member Point3D pointC = pD; //Endpoint of second member LineSegment3D lineSegment1 = new LineSegment3D(); lineSegment1.Id = openModel.GetMaxId(lineSegment1) + 1; openModel.AddObject(lineSegment1); lineSegment1.StartPoint = new ReferenceElement(pointA); lineSegment1.EndPoint = new ReferenceElement(pointB); polyLine3D.Segments.Add(new ReferenceElement(lineSegment1)); ///* //Defining LCS for First lineSegment double xcor = bearingMembers[0].ElementRAZ.line.vector.X; double ycor = bearingMembers[0].ElementRAZ.line.vector.Y; double zcor = bearingMembers[0].ElementRAZ.line.vector.Z; //Define LCS (local-y in XY plane) and unitize VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize(); VectorRAZ vy = new VectorRAZ(); VectorRAZ vz = new VectorRAZ(); if (xcor == 0.0 && ycor == 0.0) { vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize(); vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize(); } else { vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize(); vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize(); } var LocalCoordinateSystem = new CoordSystemByVector(); LocalCoordinateSystem.VecX = new Vector3D() { X = vx.X, Y = vx.Y, Z = vx.Z }; LocalCoordinateSystem.VecY = new Vector3D() { X = vy.X, Y = vy.Y, Z = vy.Z }; LocalCoordinateSystem.VecZ = new Vector3D() { X = vz.X, Y = vz.Y, Z = vz.Z }; lineSegment1.LocalCoordinateSystem = LocalCoordinateSystem; //*/ LineSegment3D lineSegment2 = new LineSegment3D(); lineSegment2.Id = openModel.GetMaxId(lineSegment2) + 1; openModel.AddObject(lineSegment2); lineSegment2.StartPoint = new ReferenceElement(pointB); lineSegment2.EndPoint = new ReferenceElement(pointC); polyLine3D.Segments.Add(new ReferenceElement(lineSegment2)); ///* /////Defining LCS for Second lineSegment double xcor2 = bearingMembers[1].ElementRAZ.line.vector.X; double ycor2 = bearingMembers[1].ElementRAZ.line.vector.Y; double zcor2 = bearingMembers[1].ElementRAZ.line.vector.Z; //Define LCS (local-y in XY plane) and unitize VectorRAZ vx2 = new VectorRAZ(xcor2, ycor2, zcor2).Unitize(); VectorRAZ vy2 = new VectorRAZ(); VectorRAZ vz2 = new VectorRAZ(); if (xcor2 == 0.0 && ycor2 == 0.0) { vy2 = new VectorRAZ(0.0, 1.0, 0.0).Unitize(); vz2 = new VectorRAZ((-zcor2), 0.0, (xcor2)).Unitize(); } else { vy2 = new VectorRAZ(-ycor2, xcor2, 0.0).Unitize(); vz2 = new VectorRAZ((-zcor2 * xcor2), (-zcor2 * ycor2), ((xcor2 * xcor2) + (ycor2 * ycor2))).Unitize(); } var LocalCoordinateSystem2 = new CoordSystemByVector(); LocalCoordinateSystem2.VecX = new Vector3D() { X = vx2.X, Y = vx2.Y, Z = vx2.Z }; LocalCoordinateSystem2.VecY = new Vector3D() { X = vy2.X, Y = vy2.Y, Z = vy2.Z }; LocalCoordinateSystem2.VecZ = new Vector3D() { X = vz2.X, Y = vz2.Y, Z = vz2.Z }; lineSegment2.LocalCoordinateSystem = LocalCoordinateSystem2; //*/ //create elements Element1D el1 = new Element1D(); //el1.Id = openModel.GetMaxId(el1) + 1; el1.Id = bearingMembers[0].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One el1.Name = "E" + el1.Id.ToString(); el1.Segment = new ReferenceElement(lineSegment1); IdeaRS.OpenModel.CrossSection.CrossSection crossSection = openModel.CrossSection.First(a => a.Id == bearingMembers[0].ElementRAZ.crossSection.id); el1.CrossSectionBegin = new ReferenceElement(crossSection); el1.CrossSectionEnd = new ReferenceElement(crossSection); openModel.AddObject(el1); Element1D el2 = new Element1D(); //el2.Id = openModel.GetMaxId(el2) + 1; el2.Id = bearingMembers[1].ElementRAZ.id + 1; //Use of Id from Grasshopper Model + Plus One el2.Name = "E" + el2.Id.ToString(); el2.Segment = new ReferenceElement(lineSegment2); el2.CrossSectionBegin = new ReferenceElement(crossSection); el2.CrossSectionEnd = new ReferenceElement(crossSection); openModel.AddObject(el2); //create member Member1D member1D = new Member1D(); member1D.Id = openModel.GetMaxId(member1D) + 1; member1D.Name = "Member" + member1D.Id.ToString(); member1D.Elements1D.Add(new ReferenceElement(el1)); member1D.Elements1D.Add(new ReferenceElement(el2)); openModel.Member1D.Add(member1D); //create connected member ConnectedMember connectedMember = new ConnectedMember(); connectedMember.Id = member1D.Id; connectedMember.MemberId = new ReferenceElement(member1D); connectionPoint.ConnectedMembers.Add(connectedMember); }