/// <summary> /// Provides information about the intersection of two circles. /// </summary> /// <param name="circle1">circle 1</param> /// <param name="circle2">circle 2</param> /// <returns> /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the circles don't touch anywhere. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if there is an overlapping area. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if circle2 lies completely inside circle1 and doesn't intersect. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.BEnclosesA"/> if circle1 lies completely inside circle2 and doesn't intersect. /// Additionally to Overlap and AEnclosesB/BEnclosesA: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Identical"/> if the centre points are equal and the radius is equal. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the outer edge of circle1 touches the outer edge of circle2. /// </returns> public static AreaCode Intersect(Circle2D circle1, Circle2D circle2) { AreaCode retval = AreaCode.Unknown; // the circles are identical if (circle1.Equals(circle2)) { retval = AreaCode.AEnclosesB | AreaCode.BEnclosesA | AreaCode.Identical | AreaCode.Intersect; } // the circles are not identical else { double distance = circle1.Centre.Distance(circle2.Centre); // the distance between the centres equals the sum of the radii // so the circles are tangents of each other if (distance == circle1.Radius + circle2.Radius) retval = AreaCode.Tangents; // the distance between the centres is greater than the sum of the radii // therefore the circles must be disjoint else if (distance > circle1.Radius + circle2.Radius) retval = AreaCode.Disjoint; // the distance between the centres is lower than the sum of the radii // therefore they must overlap in some way else if (distance < circle1.Radius + circle2.Radius) { retval = AreaCode.Overlap; // the sum of the distance and radius B is lower than radius A // therefore: A encloses B if (distance + circle2.Radius < circle1.Radius) retval = retval | AreaCode.AEnclosesB; // the sum of the distance and radius A is lower than radius B // therefore: B encloses A else if (distance + circle1.Radius < circle2.Radius) retval = retval | AreaCode.BEnclosesA; // no other possibility holds, the circles intersect else retval = retval | AreaCode.Intersect; } } return retval; }
public static void CreateCam(double angle) { double dRad = angle*dPi/180; double dDSin1 = iCircle1Rad*Math.Sin(dRad); double dDCos1 = iCircle1Rad*Math.Cos(dRad); double dDSin2 = iCircle2Rad*Math.Sin(dRad); double dDCos2 = iCircle2Rad*Math.Cos(dRad); double dCSin = iCircleDist*Math.Sin(dRad); double dCCos = iCircleDist*Math.Cos(dRad); oCurrentSketch = oPartBody.Sketches.Add ( oPlaneYZ ); Factory2D oFactory2D = oCurrentSketch.OpenEdition(); double dRad1 = dRad - dPi/4; double dRad2 = dRad + dPi/4; oCurrentLine1 = oFactory2D.CreateLine( iCenterX - dDSin1, iCenterY + dDCos1, iCenterX + dCCos + dDSin2, iCenterY - dCSin + dDCos2); oCurrentLine2 = oFactory2D.CreateLine( iCenterX + dDSin1, iCenterY - dDCos1, iCenterX + dCCos - dDSin2, iCenterY - dCSin - dDCos2 ); oCurrentCircle1 = oFactory2D.CreateCircle( iCenterX, iCenterY, iCircle1Rad, dRad2, dRad1); oCurrentCircle2 = oFactory2D.CreateCircle( iCenterX + dCCos, iCenterY + dCSin, iCircle2Rad, dRad1, dRad2); Reference oRefLine1 = oPart.CreateReferenceFromObject(oCurrentLine1); Reference oRefCircle1 = oPart.CreateReferenceFromObject(oCurrentCircle1); Reference oRefLine2 = oPart.CreateReferenceFromObject(oCurrentLine2); Reference oRefCircle2 = oPart.CreateReferenceFromObject(oCurrentCircle2); Reference oRefLine1StartPt = oPart.CreateReferenceFromObject(oCurrentLine1.StartPoint); Reference oRefLine1EndPt = oPart.CreateReferenceFromObject(oCurrentLine1.EndPoint); Reference oRefLine2StartPt = oPart.CreateReferenceFromObject(oCurrentLine2.StartPoint); Reference oRefLine2EndPt = oPart.CreateReferenceFromObject(oCurrentLine2.EndPoint); Reference oRefCircle1StartPt = oPart.CreateReferenceFromObject(oCurrentCircle1.StartPoint); Reference oRefCircle1EndPt = oPart.CreateReferenceFromObject(oCurrentCircle1.EndPoint); Reference oRefCircle2StartPt = oPart.CreateReferenceFromObject(oCurrentCircle2.StartPoint); Reference oRefCircle2EndPt = oPart.CreateReferenceFromObject(oCurrentCircle2.EndPoint); Constraints oConstraints = oCurrentSketch.Constraints; Constraint oConstraint = oConstraints.AddMonoEltCst(CatConstraintType.catCstTypeReference, oRefCircle1); oConstraint = oConstraints.AddMonoEltCst(CatConstraintType.catCstTypeReference, oRefCircle2); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine1, oRefCircle1); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefCircle2, oRefLine1); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle1StartPt, oRefLine1StartPt); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle2EndPt, oRefLine1EndPt); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine2, oRefCircle1); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine2, oRefCircle2); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle1EndPt, oRefLine2StartPt); oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle2StartPt, oRefLine2EndPt); oCurrentSketch.CloseEdition(); ShapeFactory oShapeFactory = (ShapeFactory)oPart.ShapeFactory; Pad oPad = oShapeFactory.AddNewPad ( oCurrentSketch, iCamThickness + iCurrentLevel ); oPad.SecondLimit.Dimension.Value = iCurrentLevel*-1; }
public bool IsInside(CartesianPoint point) { // Shapes var rectHull = new Rectangular2DBoundary(minX, maxX, minY, maxY); var leftCircle = new Circle2D(new CartesianPoint(leftHoleX, leftHoleY), holeRadius); var rightCircle = new Circle2D(new CartesianPoint(rightHoleX, rightHoleY), holeRadius); // Intrnal points lie inside the rectangle, but outside the circular holes. if (rectHull.IsInside(point)) { if (leftCircle.FindRelativePositionOfPoint(point) == CirclePointPosition.Outside) { return(true); } if (rightCircle.FindRelativePositionOfPoint(point) == CirclePointPosition.Outside) { return(true); } } return(false); }
public SEC() { referencepointService = new ReferencepointService(new ReferencepointRepository(new FruitFlyContext())); GetAllPoints().Wait(); // Make the clusters clusters = new List <Point2D> [k]; centroids = new Circle2D[k]; // Select k points from points and set them as centroids. // Also create the clusters for (int i = 0; i < k; i++) { clusters[i] = new List <Point2D>(); centroids[i] = new Circle2D(new Point2D(0, 0), 0); // @TODO make the point selection random // Create the center of the SEC. centroids[i].p.x = points[i].x; centroids[i].p.y = points[i].y; } }
public void setMittelpunkt(double a, double i) { // Skizze umbenennen hsp_catiaProfil.set_Name("Kreis"); // Rechteck in Skizze einzeichnen // Skizze oeffnen Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition(); Factory2D catFactory2D2 = hsp_catiaProfil.OpenEdition(); // Kreis erzeugen // erst die Punkte Circle2D circle2D = catFactory2D1.CreateCircle(0, 0, i, 0, 0); Circle2D circle3D = catFactory2D2.CreateCircle(0, 0, a, 0, 0); // Skizzierer verlassen hsp_catiaProfil.CloseEdition(); // Part aktualisieren hsp_catiaPart.Part.Update(); }
public bool ErzeugeProfilTascheRohr(Double innendurchmesser, bool skizzeerstellt) { if (skizzeerstellt == true) { if (innendurchmesser > 0) { // Skizze umbenennen catiaSketch1.set_Name("Rohrinnen"); // Rechteck in Skizze einzeichnen // Skizze oeffnen Factory2D catFactory2D1 = catiaSketch1.OpenEdition(); Circle2D circle2D1 = catFactory2D1.CreateClosedCircle(0.000000, 0.000000, innendurchmesser / 2); Point2D catPoint2D1 = catFactory2D1.CreatePoint(0, 0); circle2D1.CenterPoint = catPoint2D1; catiaSketch1.CloseEdition(); catiaPart.Part.Update(); skizzeerstellt = true; } else { MessageBox.Show("Fehler beim Erstellen des Profils:\rDie Werte dürfen nicht null sein!"); skizzeerstellt = false; } } else { MessageBox.Show("Fehler beim Erstellen des Profils:\rEs konnte keine Skizze erstellt werden!"); skizzeerstellt = false; } return(skizzeerstellt); }
/// <summary> /// If a fixed enrichment area is applied, all nodes inside a circle around the tip are enriched with tip /// functions. They can still be enriched with Heaviside functions, if they do not belong to the tip /// element(s). /// </summary> /// <param name="tipNodes"></param> /// <param name="tipElement"></param> private void ApplyFixedEnrichmentArea(HashSet <XNode> tipNodes, XContinuumElement2D tipElement) { if (tipEnrichmentAreaRadius > 0) { var enrichmentArea = new Circle2D(crackTip, tipEnrichmentAreaRadius); foreach (var element in Mesh.FindElementsInsideCircle(enrichmentArea, tipElement)) { bool completelyInside = true; foreach (var node in element.Nodes) { CirclePointPosition position = enrichmentArea.FindRelativePositionOfPoint(node); if ((position == CirclePointPosition.Inside) || (position == CirclePointPosition.On)) { tipNodes.Add(node); } else { completelyInside = false; } } if (completelyInside) { element.EnrichmentItems.Add(CrackTipEnrichments); } } #region alternatively /* // If there wasn't a need to enrich the elements, this is more performant * foreach (var node in mesh.FindNodesInsideCircle(enrichmentArea, true, tipElement)) * { * tipNodes.Add(node); // Nodes of tip element(s) will not be included twice * } */ #endregion } }
public void setUp() { center = new Point2D(12.0d, 14.0d); testCircle = new Circle2D(center, 10.0d); zeroPoint = new Point2D(0.0d, 0.0d); }
public static void CreatePatternBearing() { oCurrentSketch = oPartBody.Sketches.Add ( oPlaneYZ ); Factory2D oFactory2D = oCurrentSketch.OpenEdition(); oCurrentCircle1 = oFactory2D.CreateClosedCircle ( iCenterX, iCenterY, iBearingDiam/2 ); oCurrentSketch.CloseEdition(); ShapeFactory oShapeFactory = (ShapeFactory)oPart.ShapeFactory; Pad oPad = oShapeFactory.AddNewPad ( oCurrentSketch, iBearingLength ); OriginElements originElements1 = oPart.OriginElements; Reference oRefPlaneXY = oPart.CreateReferenceFromGeometry( oPart.OriginElements.PlaneXY ); RectPattern rectPattern1 = oShapeFactory.AddNewRectPattern(oPad,iNumberOfCylinders+1,1,iCylinderSpacing,0,1,1,oRefPlaneXY,oRefPlaneXY,true,true,0); iCurrentLevel = iBearingLength; }
private void button1_Click(object sender, EventArgs e) { INFITF.Application Catia; try { Catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { Catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); Catia.Visible = true; } INFITF.Documents Docts = Catia.Documents; MECMOD.PartDocument PrtDoc = (MECMOD.PartDocument)Docts.Add("Part"); MECMOD.Part Prt = PrtDoc.Part; MECMOD.Bodies Bodis = Prt.Bodies; MECMOD.Body PartBody = Bodis.Item(1); MECMOD.Body Body = Bodis.Add(); MECMOD.Sketches Skts = Body.Sketches; INFITF.Reference plane = (INFITF.Reference)Prt.OriginElements.PlaneXY; MECMOD.Sketch Skt = Skts.Add(plane); MECMOD.Factory2D Fac2D = Skt.OpenEdition(); Point2D Pt1 = Fac2D.CreatePoint(50, 50); Point2D Pt2 = Fac2D.CreatePoint(50, 100); Point2D Pt3 = Fac2D.CreatePoint(100, 100); Point2D Pt4 = Fac2D.CreatePoint(100, 50); // << Create Line >> Line2D Lin1 = Fac2D.CreateLine(50, 50, 50, 100); Line2D Lin2 = Fac2D.CreateLine(50, 100, 100, 100); Line2D Lin3 = Fac2D.CreateLine(100, 100, 100, 50); Line2D Lin4 = Fac2D.CreateLine(100, 50, 50, 50); // Line2D Lin22 = MCreateLine(Fac2d, Pt1, Pt2); //라인의 시작점부터 마지막점을 결정 Lin1.StartPoint = Pt1; Lin1.EndPoint = Pt2; Lin2.StartPoint = Pt2; Lin2.EndPoint = Pt3; Lin3.StartPoint = Pt3; Lin3.EndPoint = Pt4; Lin4.StartPoint = Pt4; Lin4.EndPoint = Pt1; INFITF.Reference rline1 = Prt.CreateReferenceFromGeometry(Lin1); INFITF.Reference rline2 = Prt.CreateReferenceFromGeometry(Lin2); INFITF.Reference rline3 = Prt.CreateReferenceFromGeometry(Lin3); INFITF.Reference rline4 = Prt.CreateReferenceFromGeometry(Lin4); INFITF.Reference rlineH = Prt.CreateReferenceFromGeometry(Skt.AbsoluteAxis.HorizontalReference); INFITF.Reference rlineV = Prt.CreateReferenceFromGeometry(Skt.AbsoluteAxis.VerticalReference); MECMOD.Constraint d1 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3); MECMOD.Constraint d2 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4); MECMOD.Constraint d3 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4); MECMOD.Constraint d4 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1); Skt.CloseEdition();//Skech조건 끝 // //PAD를 하기 위해서 조건문을 만든다.// PARTITF.ShapeFactory ShpFac = (PARTITF.ShapeFactory)Prt.ShapeFactory; //그 shapeFactory를 돌출하기 위해서 AddNewPad를 사용해서 50만큼 돌출한다.// ShpFac.AddNewPad(Skt, 50); //새로운 Body2를 만들기 // MECMOD.Body Body2 = Bodis.Add(); //planed을 기준으로 Skt2를 만든다.// MECMOD.Sketch Skt2 = (MECMOD.Sketch)Body2.Sketches.Add(plane); //스켓이 시작 // Fac2D = Skt2.OpenEdition(); // X=75,Y=75 를 중심으로 D=20의 원을 만들기// Circle2D Cir2D = Fac2D.CreateClosedCircle(75, 75, 20); //스켓을 끝내기// Skt2.CloseEdition(); //PAD 80만큼 // ShpFac.AddNewPad(Skt2, 80); //Body3 만들기 // Body Body3 = Prt.Bodies.Add(); //Skt3를 Body2 안에 plane면을 기준으로 Sketche를 한다. Sketch Skt3 = Body2.Sketches.Add(plane); //스킷을 시작// Fac2D = Skt3.OpenEdition(); // X=75,Y=75 를 중심으로 D=5의 원을 만들기// Fac2D.CreateClosedCircle(75, 75, 5); //스켓3을 끝내기// Skt3.CloseEdition(); //스켓3을 80만큼 PAD를 한다. ShpFac.AddNewPad(Skt3, 80); ///////////////// //PartBody에 Prat In Work Object를 사용해서 조건을 만든다. Prt.InWorkObject = PartBody; ShpFac.AddNewAdd(Body); //PartBody에 Body를추가 ShpFac.AddNewAdd(Body2); //PartBody에 Body2를추가 ShpFac.AddNewRemove(Body3); //PartBody에 Body3를 제거한다 Prt.Update(); }
public bool collide(Circle2D r) { return((r.Radius + Radius) >= (r.Center - Center).magnitude); }
static void Main(string[] args) { INFITF.Application catia; try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Appication"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); } catia.Visible = true; //open the file PartDocument prtDoc = (PartDocument)catia.Documents.Open(@"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\DraftingAABoltUsingScript\7_Drafting_the_bolt\Bolt.CATPart"); DrawingDocument drwDoc = (DrawingDocument)catia.Documents.Open(@"C:\Users\517-11\Desktop\saori\Automation\Catia-v5-Automation\DraftingAABoltUsingScript\7_Drafting_the_bolt\TitleBlock.CATDrawing"); //3.get the active sheet DrawingSheet drwSheet = drwDoc.DrawingRoot.ActiveSheet; ////4. add a new view------------------------------------------------ DrawingView FrntView = drwSheet.Views.Add("Front View"); //5.Translate the view x;400 y;150 FrntView.x = 400; FrntView.y = 150; //6.get the generativeBehavior DrawingViewGenerativeBehavior FrntVwGB = FrntView.GenerativeBehavior; // define a front view with the xy plan 1,0,0,0,1,0 FrntVwGB.DefineFrontView(1, 0, 0, 0, 1, 0); //7.assouciated the 3d docuemnt(bolt) with this view. //ref; DrawingViewGenerativeBehavior (Object) //PartDocument prtToDoc = (PartDocument)catia.Documents.Item("CATPart1"); //FrntView.GenerativeBehavior.Document = prtToDoc; FrntView.GenerativeBehavior.Document = prtDoc; //8.Add a top view x;400 y;600------------------------------------ DrawingView Topvw = drwSheet.Views.Add("TopView"); Topvw.x = 400; Topvw.y = 600; DrawingViewGenerativeBehavior TopVwGB = Topvw.GenerativeBehavior; TopVwGB.DefineProjectionView(TopVwGB, CatProjViewType.catTopView); //9. assouciated the 3d docuemnt(bolt) with this view. Topvw.GenerativeBehavior.Document = prtDoc; //10. Activate the view ----------------------------------- //& get its Factory2D to create a circle int each view. //C1(30,30,10) c2(30,,) FrntView.Activate(); Factory2D facF = FrntView.Factory2D; Circle2D c1 = facF.CreateClosedCircle(30, 30, 10); Topvw.Activate(); Factory2D facT = Topvw.Factory2D; Circle2D c2 = facT.CreateClosedCircle(30, 30, 20); //text 추가하기--------------- FrntView.Activate(); DrawingText Ftxt = FrntView.Texts.Add("Front View", 100, 100); Ftxt.SetFontSize(0, 0, 12); DrawingLeader FDleadr = Ftxt.Leaders.Add(0, 0); //txt cnrk-------------------- Topvw.Activate(); DrawingText Ttxt = Topvw.Texts.Add("Top View", -45, 130); Ttxt.SetFontSize(0, 0, 12); DrawingLeader TDleadr = Ttxt.Leaders.Add(0, 0); //table추가하기 DrawingTable table = FrntView.Tables.Add(100, 80, 2, 3, 14, 40); //table. //11. update the drawing document. drwDoc.Update(); }
internal static AreaCode Intersect(Rectangle2D rectangle2D, Circle2D circle2D) { throw new NotImplementedException(); }
public void ErzeugeProfil(Zahnrad Zahnrad1) { // geometrisches Set auswaehlen und umbenennen HybridBodies catHybridBodies1 = hsp_catiaPart.Part.HybridBodies; HybridBody catHybridBody1; try { catHybridBody1 = catHybridBodies1.Item("Geometrisches Set.1"); } catch (Exception) { MessageBox.Show("Kein geometrisches Set gefunden! " + Environment.NewLine + "Ein PART manuell erzeugen und ein darauf achten, dass 'Geometisches Set' aktiviert ist.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Information); return; } catHybridBody1.set_Name("Profile"); // neue Skizze im ausgewaehlten geometrischen Set anlegen Sketches catSketches1 = catHybridBody1.HybridSketches; OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements; Reference catReference1 = (Reference)catOriginElements.PlaneYZ; hsp_catiaProfil = catSketches1.Add(catReference1); // Achsensystem in Skizze erstellen ErzeugeAchsensystem(); // Part aktualisieren hsp_catiaPart.Part.Update(); //Nullpunkt double x0 = 0; double y0 = 0; //Hilfsgrößen von Wilkos PDF double Teilkreisradius = Zahnrad1.d / 2; double Hilfskreisradius = Teilkreisradius * 0.94; double Fußkreisradius = Teilkreisradius - (1.25 * Zahnrad1.m); double Kopfkreisradius = Teilkreisradius + Zahnrad1.m; double Verrundungsradius = 0.35 * Zahnrad1.m; double Alpha = 20; double Beta = 90 / Zahnrad1.z; double Betarad = Math.PI * Beta / 180; double Gamma = 90 - (Alpha - Beta); double Gammarad = Math.PI * Gamma / 180; double Totalangel = 360.0 / Zahnrad1.z; double Totalangelrad = Math.PI * Totalangel / 180; //Punkte //LinkerEvolKreis Mittelp. Koordinaten double xMPEvo_links = Hilfskreisradius * Math.Cos(Gammarad); double yMPEvo_links = Hilfskreisradius * Math.Sin(Gammarad); //Schnittpkt. auf Evolvente und Teilkreisradius double xPunktAufEvolvente = -Teilkreisradius *Math.Sin(Betarad); double yPunktAufEvolvente = Teilkreisradius * Math.Cos(Betarad); //Evolventenkreis Radius double EvolventenkreisRadius = Math.Sqrt(Math.Pow((xMPEvo_links - xPunktAufEvolvente), 2) + Math.Pow((yMPEvo_links - yPunktAufEvolvente), 2)); //Koordinaten Schnittpunkt Kopfkreis und Evolventenkreis double xEvolventenkopfkreis_links = Schnittpunkt_X(x0, y0, Kopfkreisradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius); double yEvolventenkopfkreis_links = Schnittpunkt_Y(x0, y0, Kopfkreisradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius); //Mittelpunktkoordinaten Verrundung double xMittelpunktVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius + Verrundungsradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius + Verrundungsradius); double yMittelpunktVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius + Verrundungsradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius + Verrundungsradius); //Schnittpubktkoordinaten Verrundung - Evolventenkreis double x_SP_EvolventeVerrundung_links = Schnittpunkt_X(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); double y_SP_EvolventeVerrundung_links = Schnittpunkt_Y(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); //Schnittpunktkoordinaten Verrundung - Fußkreis double x_SP_FußkreisradiusVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); double y_SP_FußkreisradiusVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); //Koordinaten Anfangspunkt Fußkreis double Hilfswinkel = Totalangelrad - Math.Atan(Math.Abs(x_SP_FußkreisradiusVerrundung_links) / Math.Abs(y_SP_FußkreisradiusVerrundung_links)); double x_AnfangspunktFußkreis = Fußkreisradius * Math.Sin(Hilfswinkel); double y_AnfangspunktFußkreis = Fußkreisradius * Math.Cos(Hilfswinkel); //Skizze umbenennen und öffnen hsp_catiaProfil.set_Name("Zahnradskizze"); Factory2D catfactory2D1 = hsp_catiaProfil.OpenEdition(); //Nun die Punkte in die Skizze Point2D Ursprung = catfactory2D1.CreatePoint(x0, y0); Point2D EndpunktEvolventenkreis = catfactory2D1.CreatePoint(x_AnfangspunktFußkreis, y_AnfangspunktFußkreis); Point2D VerrundungLinksAnfang = catfactory2D1.CreatePoint(x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links); Point2D VerrundungRechtsEnde = catfactory2D1.CreatePoint(-x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links); Point2D MPVerrundungLinks = catfactory2D1.CreatePoint(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links); Point2D MPVerrundungRechts = catfactory2D1.CreatePoint(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links); Point2D VerrundungEndeLinks = catfactory2D1.CreatePoint(x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links); Point2D VerrundungAnfangRechts = catfactory2D1.CreatePoint(-x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links); Point2D MPEvolventeLinks = catfactory2D1.CreatePoint(xMPEvo_links, yMPEvo_links); Point2D MPEvolventeRechts = catfactory2D1.CreatePoint(-xMPEvo_links, yMPEvo_links); Point2D EvolventenEndeLinks = catfactory2D1.CreatePoint(xEvolventenkopfkreis_links, yEvolventenkopfkreis_links); Point2D EvolventenEndeRechts = catfactory2D1.CreatePoint(-xEvolventenkopfkreis_links, yEvolventenkopfkreis_links); //Kreise Circle2D Fußkreis = catfactory2D1.CreateCircle(x0, y0, Fußkreisradius, 0, Math.PI * 2); Fußkreis.CenterPoint = Ursprung; Fußkreis.StartPoint = EndpunktEvolventenkreis; Fußkreis.EndPoint = VerrundungRechtsEnde; Circle2D VerrundungLinks = catfactory2D1.CreateCircle(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2); VerrundungLinks.CenterPoint = MPVerrundungLinks; VerrundungLinks.StartPoint = VerrundungLinksAnfang; VerrundungLinks.EndPoint = VerrundungEndeLinks; Circle2D EvolventenkreisLinks = catfactory2D1.CreateCircle(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, 0, Math.PI * 2); EvolventenkreisLinks.CenterPoint = MPEvolventeLinks; EvolventenkreisLinks.StartPoint = EvolventenEndeLinks; EvolventenkreisLinks.EndPoint = VerrundungEndeLinks; Circle2D Kopfkreis = catfactory2D1.CreateCircle(x0, y0, Kopfkreisradius, 0, Math.PI * 2); Kopfkreis.CenterPoint = Ursprung; Kopfkreis.StartPoint = EvolventenEndeRechts; Kopfkreis.EndPoint = EvolventenEndeLinks; Circle2D EvolventenkreisRechts = catfactory2D1.CreateCircle(-xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, 0, Math.PI * 2); EvolventenkreisRechts.CenterPoint = MPEvolventeRechts; EvolventenkreisRechts.StartPoint = VerrundungAnfangRechts; EvolventenkreisRechts.EndPoint = EvolventenEndeRechts; Circle2D VerrundungRechts = catfactory2D1.CreateCircle(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2); VerrundungRechts.CenterPoint = MPVerrundungRechts; VerrundungRechts.StartPoint = VerrundungAnfangRechts; VerrundungRechts.EndPoint = VerrundungRechtsEnde; // Skizzierer verlassen hsp_catiaProfil.CloseEdition(); // Part aktualisieren hsp_catiaPart.Part.Update(); ShapeFactory shapeFactory1 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; HybridShapeFactory hybridShapeFactory1 = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory; Factory2D factory2D1 = hsp_catiaProfil.Factory2D; HybridShapePointCoord ursprung = hybridShapeFactory1.AddNewPointCoord(0, 0, 0); Reference refUrsprung = hsp_catiaPart.Part.CreateReferenceFromObject(ursprung); HybridShapeDirection xRichtung = hybridShapeFactory1.AddNewDirectionByCoord(1, 0, 0); Reference refxRichtung = hsp_catiaPart.Part.CreateReferenceFromObject(xRichtung); CircPattern kreismuster = shapeFactory1.AddNewSurfacicCircPattern(factory2D1, 1, 2, 0, 0, 1, 1, refUrsprung, refxRichtung, false, 0, true, false); kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing; AngularRepartition angularRepartition1 = kreismuster.AngularRepartition; Angle angle1 = angularRepartition1.AngularSpacing; angle1.Value = Convert.ToDouble(360 / Zahnrad1.z); AngularRepartition angularRepartition2 = kreismuster.AngularRepartition; IntParam intParam1 = angularRepartition2.InstancesCount; intParam1.Value = Convert.ToInt32(Zahnrad1.z) + 1; //Kreismusterenden verbinden Reference refKreismuster = hsp_catiaPart.Part.CreateReferenceFromObject(kreismuster); HybridShapeAssemble verbindung = hybridShapeFactory1.AddNewJoin(refKreismuster, refKreismuster); Reference refVerbindung = hsp_catiaPart.Part.CreateReferenceFromObject(verbindung); hybridShapeFactory1.GSMVisibility(refVerbindung, 0); hsp_catiaPart.Part.MainBody.InsertHybridShape(verbindung); hsp_catiaPart.Part.Update(); ErzeugeBlock(Zahnrad1, refVerbindung, shapeFactory1); Sketches sketchesBohrung = catHybridBody1.HybridSketches; OriginElements catoriginelements = hsp_catiaPart.Part.OriginElements; Reference refmxPlaneX = (Reference)catoriginelements.PlaneYZ; hsp_catiaProfil = catSketches1.Add(refmxPlaneX); ErzeugeAchsensystem(); hsp_catiaPart.Part.Update(); hsp_catiaProfil.set_Name("Bohrung"); Factory2D catfactory2D2 = hsp_catiaProfil.OpenEdition(); Circle2D KreisFürBohrungsskizze = catfactory2D2.CreateClosedCircle(x0, y0, Zahnrad1.bd / 2); hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody; Pocket Tasche = shapeFactory1.AddNewPocket(hsp_catiaProfil, Zahnrad1.b); hsp_catiaPart.Part.Update(); }
//InnenVerzahnung public void ErstelleProfilInnen(Data dat) { //geometrisches set auswählen und umbenennen HybridBodies catHybridBodies_I = hsp_catiaPart.Part.HybridBodies; HybridBody catHybridBody_I; try { catHybridBody_I = catHybridBodies_I.Item("Geometrisches Set.1"); } catch (Exception) { MessageBox.Show("Kein geometrisches Set gefunden!\nEin PART manuell erzeugen und darauf achten, dass ein 'Geometisches Set' aktiviert ist.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); return; } catHybridBody_I.set_Name("Profile"); //Neue Skizze im ausgewählten geometrischen Set anlegen Sketches catSketches_I = catHybridBody_I.HybridSketches; OriginElements catOriginElements_I = hsp_catiaPart.Part.OriginElements; Reference catReference_I = (Reference)catOriginElements_I.PlaneYZ; hsp_catiaProfil = catSketches_I.Add(catReference_I); //Achsensystem in Skizze erzeugen ErzeugeAchsensystem(); //Part aktualisieren hsp_catiaPart.Part.Update(); hsp_catiaProfil.set_Name("InnenverzahnungBlock"); Factory2D catFactory_I = hsp_catiaProfil.OpenEdition(); Circle2D catC2D_I = catFactory_I.CreateClosedCircle(0, 0, dat.getFußkreisdurchmesser_iZahnrad1()); hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); ShapeFactory SF_I = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; HybridShapeFactory HSF_I = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory; //Erzeuge Block aus Skizze hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody; Pad myPad = SF_I.AddNewPad(hsp_catiaProfil, dat.getBreiteZahnrad1()); hsp_catiaPart.Part.Update(); //Neue Skizze im ausgewählten geometrischen Set anlegen Sketches catSketches1 = catHybridBody_I.HybridSketches; OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements; Reference catReference1 = (Reference)catOriginElements.PlaneYZ; hsp_catiaProfil = catSketches1.Add(catReference1); //Achsensystem in Skizze erzeugen ErzeugeAchsensystem(); //Part aktualisieren hsp_catiaPart.Part.Update(); //HilfsRadien double d_r = (dat.getModulZahnrad1() * dat.getZaehnezahlZahnrad1()) / 2; double hk_r = d_r * 1.06; double da_r = d_r - (1.25 * dat.getModulZahnrad1()); double df_r = d_r + dat.getModulZahnrad1(); double vd_r = 0.35 * dat.getModulZahnrad1(); //HilfsWinkel double alpha = 20; double beta = 90 / dat.getZaehnezahlZahnrad1(); double beta_r = Math.PI * beta / 180; double gamma = 90 - (alpha - beta); double gamma_r = Math.PI * gamma / 180; double ta = 360.0 / dat.getZaehnezahlZahnrad1(); double ta_r = Math.PI * ta / 180; //Nullpunkte double x0 = 0; double y0 = 0; //MittelPunkt EvolventenKreis double MP_EvolventenKreis_x = hk_r * Math.Cos(gamma_r); double MP_EvolventenKreis_y = hk_r * Math.Sin(gamma_r); // SchnittPunkt Evolventenkreis & Teilkreisradius double SP_EvolventenTeilKreis_x = -d_r *Math.Sin(beta_r); double SP_EvolventenTeilKreis_y = d_r * Math.Cos(beta_r); //Evolventenkreis Radius double Evolventenkreis_r = Math.Sqrt(Math.Pow((MP_EvolventenKreis_x - SP_EvolventenTeilKreis_x), 2) + Math.Pow((MP_EvolventenKreis_y - SP_EvolventenTeilKreis_y), 2)); //SchnittPunkt Evolventenkreis & Kopfkreisradius double SP_EvolventenKopfKreis_x = Schnittpunkt_x(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r); double SP_EvolventenKopfKreis_y = Schnittpunkt_y(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r); //MittelPunkt VerrundungsRadius double MP_Verrundung_x = Schnittpunkt_x(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r); double MP_Verrundung_y = Schnittpunkt_y(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r); //SchnittPunkt Evolventenkreis & Verrundungsradius double SP_EvolventeVerrundung_x = Schnittpunkt_x(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); double SP_EvolventeVerrundung_y = Schnittpunkt_y(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); //SchnittPunkt Fußkreis & Verrundungs Radius double SP_FußkreisVerrundungsRadius_x = Schnittpunkt_x(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); double SP_FußkreisVerrundungsRadius_y = Schnittpunkt_y(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); //StartPunkt Fußkreis Radius double phi = ta_r - Math.Atan(Math.Abs(SP_FußkreisVerrundungsRadius_x) / Math.Abs(SP_FußkreisVerrundungsRadius_y)); double StartPkt_Fußkreis_x = -df_r *Math.Sin(phi); double StartPkt_Fußkreis_y = df_r * Math.Cos(phi); //Skizze umbenennen und öffnen hsp_catiaProfil.set_Name("InnenverzahnungEinzel"); Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition(); //Punkte Point2D catP2D_Ursprung = catFactory2D1.CreatePoint(x0, y0); Point2D catP2D_StartPkt_Fußkreis = catFactory2D1.CreatePoint(StartPkt_Fußkreis_x, StartPkt_Fußkreis_y); Point2D catP2D_SP_FußkreisVerrundungsRadius1 = catFactory2D1.CreatePoint(SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y); Point2D catP2D_SP_FußkreisVerrundungsRadius2 = catFactory2D1.CreatePoint(-SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y); Point2D catP2D_MP_EvolventenKreis1 = catFactory2D1.CreatePoint(MP_EvolventenKreis_x, MP_EvolventenKreis_y); Point2D catP2D_MP_EvolventenKreis2 = catFactory2D1.CreatePoint(-MP_EvolventenKreis_x, MP_EvolventenKreis_y); Point2D catP2D_SP_EvolventenKopfKreis1 = catFactory2D1.CreatePoint(SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y); Point2D catP2D_SP_EvolventenKopfKreis2 = catFactory2D1.CreatePoint(-SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y); Point2D catP2D_MP_Verrundung1 = catFactory2D1.CreatePoint(MP_Verrundung_x, MP_Verrundung_y); Point2D catP2D_MP_Verrundung2 = catFactory2D1.CreatePoint(-MP_Verrundung_x, MP_Verrundung_y); Point2D catP2D_SP_EvolventeVerrundung1 = catFactory2D1.CreatePoint(SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y); Point2D catP2D_SP_EvolventeVerrundung2 = catFactory2D1.CreatePoint(-SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y); //Kreise Circle2D catC2D_Frußkreis = catFactory2D1.CreateCircle(x0, y0, df_r, 0, 0); catC2D_Frußkreis.CenterPoint = catP2D_Ursprung; catC2D_Frußkreis.StartPoint = catP2D_SP_FußkreisVerrundungsRadius1; catC2D_Frußkreis.EndPoint = catP2D_StartPkt_Fußkreis; Circle2D catC2D_Kopfkreis = catFactory2D1.CreateCircle(x0, y0, da_r, 0, 0); catC2D_Kopfkreis.CenterPoint = catP2D_Ursprung; catC2D_Kopfkreis.StartPoint = catP2D_SP_EvolventenKopfKreis2; catC2D_Kopfkreis.EndPoint = catP2D_SP_EvolventenKopfKreis1; Circle2D catC2D_EvolventenKreis1 = catFactory2D1.CreateCircle(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0); catC2D_EvolventenKreis1.CenterPoint = catP2D_MP_EvolventenKreis1; catC2D_EvolventenKreis1.StartPoint = catP2D_SP_EvolventenKopfKreis1; catC2D_EvolventenKreis1.EndPoint = catP2D_SP_EvolventeVerrundung1; Circle2D catC2D_Evolventenkreis2 = catFactory2D1.CreateCircle(-MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0); catC2D_Evolventenkreis2.CenterPoint = catP2D_MP_EvolventenKreis2; catC2D_Evolventenkreis2.StartPoint = catP2D_SP_EvolventeVerrundung2; catC2D_Evolventenkreis2.EndPoint = catP2D_SP_EvolventenKopfKreis2; Circle2D catC2D_VerrundungsKreis1 = catFactory2D1.CreateCircle(MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0); catC2D_VerrundungsKreis1.CenterPoint = catP2D_MP_Verrundung1; catC2D_VerrundungsKreis1.StartPoint = catP2D_SP_FußkreisVerrundungsRadius1; catC2D_VerrundungsKreis1.EndPoint = catP2D_SP_EvolventeVerrundung1; Circle2D catC2D_VerrundungsKreis2 = catFactory2D1.CreateCircle(-MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0); catC2D_VerrundungsKreis2.CenterPoint = catP2D_MP_Verrundung2; catC2D_VerrundungsKreis2.StartPoint = catP2D_SP_EvolventeVerrundung2; catC2D_VerrundungsKreis2.EndPoint = catP2D_SP_FußkreisVerrundungsRadius2; hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); //Skizze und Referenzen Factory2D Factory2D1 = hsp_catiaProfil.Factory2D; HybridShapePointCoord Ursprung = HSF_I.AddNewPointCoord(0, 0, 0); Reference RefUrsprung = hsp_catiaPart.Part.CreateReferenceFromObject(Ursprung); HybridShapeDirection XDir = HSF_I.AddNewDirectionByCoord(1, 0, 0); Reference RefXDir = hsp_catiaPart.Part.CreateReferenceFromObject(XDir); //Kreismuster mit Daten füllen CircPattern Kreismuster = SF_I.AddNewSurfacicCircPattern(Factory2D1, 1, 2, 0, 0, 1, 1, RefUrsprung, RefXDir, false, 0, true, false); Kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing; AngularRepartition angularRepartition1 = Kreismuster.AngularRepartition; Angle angle1 = angularRepartition1.AngularSpacing; angle1.Value = Convert.ToDouble(360 / dat.getZaehnezahlZahnrad1()); AngularRepartition angularRepartition2 = Kreismuster.AngularRepartition; IntParam intParam1 = angularRepartition2.InstancesCount; intParam1.Value = Convert.ToInt32(dat.getZaehnezahlZahnrad1()) + 1; //geschlossene Kontur Reference Ref_Kreismuster = hsp_catiaPart.Part.CreateReferenceFromObject(Kreismuster); HybridShapeAssemble Verbindung = HSF_I.AddNewJoin(Ref_Kreismuster, Ref_Kreismuster); Reference Ref_Verbindung = hsp_catiaPart.Part.CreateReferenceFromObject(Verbindung); HSF_I.GSMVisibility(Ref_Verbindung, 0); hsp_catiaPart.Part.Update(); /*Bodies bodies = hsp_catiaPart.Part.Bodies; * Body myBody = bodies.Add(); * myBody.set_Name("Zahnrad"); * myBody.InsertHybridShape(Verbindung); * * hsp_catiaPart.Part.Update();*/ //Tasche für Innenverzahnung(grob) hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody; Pocket catPocketInnen = SF_I.AddNewPocketFromRef(Ref_Verbindung, dat.getBreiteZahnrad1()); hsp_catiaPart.Part.Update(); }
/// <summary> /// Provides information about if the point lies in the circle. /// </summary> /// <param name="circle2D">The circle.</param> /// <param name="point">The point.</param> /// <returns> /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the point lies outside the circle. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if the point lies inside or on the circle edge. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if the point lies inside and not on the edge. /// Additionally to Overlap and AEnclosesB: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Identical"/> if the point equals the centre point of the circle. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the point lies on the edge of the circle. /// </returns> public static AreaCode Intersect(Circle2D circle2D, Point point) { AreaCode retval = AreaCode.Unknown; if (circle2D.Centre.Distance((Point)point) < circle2D.Radius) retval = AreaCode.Overlap | AreaCode.AEnclosesB; else if (circle2D.Centre.Equals(point)) retval = AreaCode.Overlap | AreaCode.AEnclosesB | AreaCode.Identical; else if (circle2D.Centre.Distance((Point)point) == circle2D.Radius) retval = AreaCode.Overlap | AreaCode.Tangents; else retval = AreaCode.Disjoint; return retval; }
// private Border FindNextBorder() // { // // Alle Cluster enthalten zwei Punkte. Suche einen Joint, dessen angeschlossener // // ICurve2D länger als maxGap ist (warum eigentlich?) // // Gehe solange durch die Cluster, bis wieder der erste Punkt erreicht ist // Joint StartWith = null; // foreach (Cluster cl in clusterSet) // { // foreach (Joint lp in cl.Points) // { // if (lp.curve.Length>maxGap) // { // StartWith = lp; // RemoveJoint(lp,cl); // break; // } // } // if (StartWith!=null) break; // } // if (StartWith==null) return null; // keinen Anfang gefunden // Joint LastPoint = StartWith; // Cluster goon = null; // BorderBuilder makeBorder = new BorderBuilder(); // makeBorder.Precision = clusterSize; // while ((goon = ExtractCurve(LastPoint.curve,!LastPoint.isStartPoint))!=null) // { // makeBorder.AddSegment(LastPoint.curve.CloneReverse(!LastPoint.isStartPoint)); // if (goon.Points.Count==0) break; // auf den letzten und ersten Punkt gestoßen // LastPoint = (Joint)goon.Points[0]; // es sollte ja nur diesen einen geben // RemoveJoint(LastPoint,goon); // damit müsste dieser Cluster verschwinden // } // return makeBorder.BuildBorder(); // } // private bool FindSimpleBorder(Set clusterSet, ArrayList AllBorders, Set UsedJoints, ICurve2D startWith, bool forward) // { // Set tmpUsedJoints = new Set(); // tmpUsedJoints.Add(new UsedJoint(startWith,forward)); // // Anfangskante gefunden, wie gehts weiter // BorderBuilder bb = new BorderBuilder(); // bb.Precision = clusterSize; // if (forward) bb.AddSegment(startWith.Clone()); // else bb.AddSegment(startWith.CloneReverse(true)); // // while (!bb.IsClosed) // { // Cluster cl = FindCluster(startWith, bb.EndPoint, false); // if (cl==null) return false; // eine angefangene Border geht nicht weiter, sollte nicht passieren, da keine Sackgassen // int ind = -1; // double sa = -1.0; // for (int i=0; i<cl.Points.Count; ++i) // { // Joint j = cl.Points[i] as Joint; // if (j.curve==startWith) continue; // nicht auf der Stelle rückwärts weiter // UsedJoint uj = new UsedJoint(j.curve,j.isStartPoint); // if (!UsedJoints.Contains(uj) && !tmpUsedJoints.Contains(uj)) // { // SweepAngle d; // if (j.isStartPoint) d = new SweepAngle(bb.EndDirection,j.curve.StartDirection); // else d = new SweepAngle(bb.EndDirection,j.curve.EndDirection.Opposite()); // // d zwischen -PI und +PI // if (d+Math.PI > sa) // { // je mehr nach links umso größer is d // sa = d+Math.PI; // ind = i; // } // } // } // if (ind>=0) // { // Joint j = cl.Points[ind] as Joint; // if (j.isStartPoint) bb.AddSegment(j.curve.Clone()); // else bb.AddSegment(j.curve.CloneReverse(true)); // tmpUsedJoints.Add(new UsedJoint(j.curve,j.isStartPoint)); // startWith = j.curve; // } // else // { // return false; // kein weitergehen möglich // } // } // if (bb.IsOriented) // { // Border bdr = bb.BuildBorder(); // AllBorders.Add(bdr); // foreach (UsedJoint uj in tmpUsedJoints) // { // if (!UsedJoints.Contains(uj)) // { // UsedJoints.Add(uj); // } // else // { // int dbg = 0; // } // } // return true; // } // return false; // } // private bool FindSimpleBorder(Set clusterSet, ArrayList AllBorders, Set UsedJoints) // { // // es wird eine minimale Border gesucht: von irgend einem Cluster ausgehend immer // // linksrum bis man wieder am Anfang ist. // // UsedJoints enthält UsedJoint objekte, damit man feststellen kann, ob eine Kante bereits // // benutzt ist oder nicht // ICurve2D startWith = null; // bool forward = false; // foreach (Cluster cl in clusterSet) // { // for (int i=0; i<cl.Points.Count; ++i) // { // UsedJoint uj = new UsedJoint(); // Joint j = cl.Points[i] as Joint; // uj.curve = j.curve; // uj.forward = true; // if (!UsedJoints.Contains(uj)) // { // forward = j.isStartPoint; // startWith = j.curve; // if (FindSimpleBorder(clusterSet,AllBorders,UsedJoints,startWith,forward)) // return true; // } // uj.forward = false; // if (!UsedJoints.Contains(uj)) // { // forward = !j.isStartPoint; // startWith = j.curve; // if (FindSimpleBorder(clusterSet,AllBorders,UsedJoints,startWith,forward)) // return true; // } // } // } // return false; // } private Joint[] SortCluster() { // sortiert die Kanten (Joints) in einem Cluster im Gegenuhrzeigersinn // liefert alle Kanten // Verwerfen von identischen Kanten: // Zwei Kanten in einem Cluster, die das selbe "Gegencluster" haben // stehen im Verdacht identisch zu sein. Ihre Mittelpunkte werden auf // identität überprüft und die Kanten werden ggf. entfernt. foreach (Cluster cl in clusterSet) { for (int i = 0; i < cl.Joints.Count - 1; ++i) { int duplicate = -1; for (int j = i + 1; j < cl.Joints.Count; ++j) { Cluster cl1; Cluster cl2; Joint j1 = cl.Joints[i] as Joint; Joint j2 = cl.Joints[j] as Joint; if (j1.StartCluster == cl) { cl1 = j1.EndCluster; } else { cl1 = j1.StartCluster; } if (j2.StartCluster == cl) { cl2 = j2.EndCluster; } else { cl2 = j2.StartCluster; } if (cl1 == cl2) { // zwei Kanten verbinden dieselben Cluster. Sie könnten identisch sein ICurve2D curve1 = j1.curve.CloneReverse(j1.StartCluster != cl); ICurve2D curve2 = j2.curve.CloneReverse(j2.StartCluster != cl); // curve1 und curve2 haben jetzt die selbe Richtung GeoPoint2D p1 = curve1.PointAt(0.5); GeoPoint2D p2 = curve2.PointAt(0.5); if (Geometry.Dist(p1, p2) < clusterSize) { duplicate = j; break; } } } if (duplicate > 0) { cl.Joints.RemoveAt(duplicate); } } } // zu kurze Joints werden entfern foreach (Cluster cl in clusterSet) { for (int i = cl.Joints.Count - 1; i >= 0; --i) { Joint j1 = cl.Joints[i] as Joint; if (j1.curve.Length < this.clusterSize) { cl.Joints.RemoveAt(i); } } } UntypedSet allJoints = new UntypedSet(); foreach (Cluster cl in clusterSet) { if (cl.Joints.Count < 3) { foreach (Joint j in cl.Joints) { if (!allJoints.Contains(j)) { allJoints.Add(j); } } continue; } // zwei Punkte im cluster muss man nicht sortieren double minDist = double.MaxValue; foreach (Joint j in cl.Joints) { if (!allJoints.Contains(j)) { allJoints.Add(j); } GeoPoint2D p; if (j.StartCluster == cl) { p = j.EndCluster.center; } else { if (j.EndCluster != cl) { throw new CurveGraphException("SortCluster"); } p = j.StartCluster.center; } double d = Geometry.Dist(cl.center, p); if (d == 0.0) { if (j.StartCluster == j.EndCluster) { continue; } throw new CurveGraphException("SortCluster"); } if (d < minDist) { minDist = d; } } // Kreis um cl mit halber Entfernung zum nächsten Knoten als Radius Circle2D c2d = new Circle2D(cl.center, minDist / 2.0); foreach (Joint j in cl.Joints) { GeoPoint2DWithParameter[] ip = c2d.Intersect(j.curve); if (ip.Length > 0) { for (int i = 0; i < ip.Length; ++i) { if (j.curve.IsParameterOnCurve(ip[i].par2)) { Angle a = new Angle(ip[i].p, cl.center); j.tmpAngle = a.Radian; break; } } } else { // darf nicht vorkommen, eine Kante schneidet nicht den Kreis um // den Knoten mit halbem Radius zum nächsten knoten // der Sortierwert bleibt halt 0.0, aber man sollte solche Kanten // entfernen ... // kommt vor, das Problem liegt bei regle4!!! if (j.StartCluster == cl) { // curve startet hier j.tmpAngle = j.curve.StartDirection.Angle; } else { j.tmpAngle = j.curve.EndDirection.Opposite().Angle; } } } cl.Joints.Sort(); // es wird nach tmpAngle sortiert } Joint[] res = new Joint[allJoints.Count]; int ii = 0; foreach (Joint j in allJoints) { // die Kurve exakt ausrichten try { j.curve.StartPoint = j.StartCluster.center; j.curve.EndPoint = j.EndCluster.center; } catch (Curve2DException) { } // z.B. Kreise endpunkt setzen res[ii] = j; ++ii; } return(res); }
/// <summary> /// Provides information about if the stroke intersects the circle. /// </summary> /// <param name="stroke">The stroke.</param> /// <returns> /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the stroke lies outside the circle. /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if the stroke lies inside, intersects or is a tangent of the circle. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if the stroke lies completely inside the circle. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Intersect"/> if the stroke intersects the circle. /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the stroke is a tangent of the circle. /// </returns> public static AreaCode Intersect(Circle2D circle2D, IStroke stroke) { throw new NotImplementedException(); }
public static AreaCode Intersect(Circle2D circle2D, Square2D square2D) { return Area.Intersect(circle2D, square2D as Rectangle2D); }
public void SonderIPE_DrawSketch(double SonderIPE_Breite, double SonderIPE_Hoehe, double Flanschbreite, double Stegbreite) { double b = SonderIPE_Breite; double h = SonderIPE_Hoehe; double f = Flanschbreite; double s = Stegbreite; double R = 2 * s; // Definition des Eckenradius nach DIN 1025-2 und DIN 1025-5 double bs = (b - s) / 2; CATIA_SonderIPE_2D.set_Name("I-Profil"); Factory2D SonderIPE_Factory = CATIA_SonderIPE_2D.OpenEdition(); // Definition der Geometrie // Definition der Radienmittelpunkte Point2D Mittelpunkt1 = SonderIPE_Factory.CreatePoint((bs - R), (f + R)); Point2D Mittelpunkt2 = SonderIPE_Factory.CreatePoint((bs + s + R), (f + R)); Point2D Mittelpunkt3 = SonderIPE_Factory.CreatePoint((bs + s + R), (h - f - R)); Point2D Mittelpunkt4 = SonderIPE_Factory.CreatePoint((bs - R), (h - f - R)); // Definition der Konturpunkte Point2D Konturpunkt1 = SonderIPE_Factory.CreatePoint(0, 0); Point2D Konturpunkt2 = SonderIPE_Factory.CreatePoint(b, 0); Point2D Konturpunkt3 = SonderIPE_Factory.CreatePoint(b, f); Point2D Konturpunkt4 = SonderIPE_Factory.CreatePoint((bs + s + R), f); Point2D Konturpunkt5 = SonderIPE_Factory.CreatePoint((bs + s), (f + R)); Point2D Konturpunkt6 = SonderIPE_Factory.CreatePoint((bs + s), (h - f - R)); Point2D Konturpunkt7 = SonderIPE_Factory.CreatePoint((bs + s + R), (h - f)); Point2D Konturpunkt8 = SonderIPE_Factory.CreatePoint(b, (h - f)); Point2D Konturpunkt9 = SonderIPE_Factory.CreatePoint(b, h); Point2D Konturpunkt10 = SonderIPE_Factory.CreatePoint(0, h); Point2D Konturpunkt11 = SonderIPE_Factory.CreatePoint(0, (h - f)); Point2D Konturpunkt12 = SonderIPE_Factory.CreatePoint((bs - R), (h - f)); Point2D Konturpunkt13 = SonderIPE_Factory.CreatePoint(bs, (h - f - R)); Point2D Konturpunkt14 = SonderIPE_Factory.CreatePoint(bs, (f + R)); Point2D Konturpunkt15 = SonderIPE_Factory.CreatePoint((bs - R), f); Point2D Konturpunkt16 = SonderIPE_Factory.CreatePoint(0, f); // Defintion der Linien Line2D Linie12 = SonderIPE_Factory.CreateLine(0, 0, b, 0); Linie12.StartPoint = Konturpunkt1; Linie12.EndPoint = Konturpunkt2; Line2D Linie23 = SonderIPE_Factory.CreateLine(b, 0, b, f); Linie23.StartPoint = Konturpunkt2; Linie23.EndPoint = Konturpunkt3; Line2D Linie34 = SonderIPE_Factory.CreateLine(b, f, (bs + s + R), f); Linie34.StartPoint = Konturpunkt3; Linie34.EndPoint = Konturpunkt4; Line2D Linie56 = SonderIPE_Factory.CreateLine((bs + s), (f + R), (bs + s), (h - f - R)); Linie56.StartPoint = Konturpunkt5; Linie56.EndPoint = Konturpunkt6; Line2D Linie78 = SonderIPE_Factory.CreateLine((bs + s + R), (h - f), b, (h - f)); Linie78.StartPoint = Konturpunkt7; Linie78.EndPoint = Konturpunkt8; Line2D Linie89 = SonderIPE_Factory.CreateLine(b, (h - f), b, h); Linie89.StartPoint = Konturpunkt8; Linie89.EndPoint = Konturpunkt9; Line2D Linie910 = SonderIPE_Factory.CreateLine(b, h, 0, h); Linie910.StartPoint = Konturpunkt9; Linie910.EndPoint = Konturpunkt10; Line2D Linie1011 = SonderIPE_Factory.CreateLine(0, h, 0, (h - f)); Linie1011.StartPoint = Konturpunkt10; Linie1011.EndPoint = Konturpunkt11; Line2D Linie1112 = SonderIPE_Factory.CreateLine(0, (h - f), (bs - R), (h - f)); Linie1112.StartPoint = Konturpunkt11; Linie1112.EndPoint = Konturpunkt12; Line2D Linie1314 = SonderIPE_Factory.CreateLine(bs, (h - f - R), bs, (f + R)); Linie1314.StartPoint = Konturpunkt13; Linie1314.EndPoint = Konturpunkt14; Line2D Linie1516 = SonderIPE_Factory.CreateLine((bs - R), f, 0, f); Linie1516.StartPoint = Konturpunkt15; Linie1516.EndPoint = Konturpunkt16; Line2D Linie161 = SonderIPE_Factory.CreateLine(0, f, 0, 0); Linie161.StartPoint = Konturpunkt16; Linie161.EndPoint = Konturpunkt1; // Definition der Eckenverrundungen Circle2D Eckenverrundung1 = SonderIPE_Factory.CreateCircle((bs - R), (f + R), R, 0, 0); Eckenverrundung1.CenterPoint = Mittelpunkt1; Eckenverrundung1.StartPoint = Konturpunkt15; Eckenverrundung1.EndPoint = Konturpunkt14; Circle2D Eckenverrundung2 = SonderIPE_Factory.CreateCircle((bs + s + R), (f + R), R, 0, 0); Eckenverrundung2.CenterPoint = Mittelpunkt2; Eckenverrundung2.StartPoint = Konturpunkt5; Eckenverrundung2.EndPoint = Konturpunkt4; Circle2D Eckenverrundung3 = SonderIPE_Factory.CreateCircle((bs + s + R), (h - f - R), R, 0, 0); Eckenverrundung3.CenterPoint = Mittelpunkt3; Eckenverrundung3.StartPoint = Konturpunkt7; Eckenverrundung3.EndPoint = Konturpunkt6; Circle2D Eckenverrundung4 = SonderIPE_Factory.CreateCircle((bs - R), (h - f - R), R, 0, 0); Eckenverrundung4.CenterPoint = Mittelpunkt4; Eckenverrundung4.StartPoint = Konturpunkt13; Eckenverrundung4.EndPoint = Konturpunkt12; CATIA_SonderIPE_2D.CloseEdition(); CATIA_SonderIPE_Part.Part.Update(); }
// #if UNITY_EDITOR // public virtual void DrawGizmos (Color color) // { // GizmosManager.GizmosEntry gizmosEntry = new GizmosManager.GizmosEntry(); // gizmosEntry.setColor = true; // gizmosEntry.color = color; // gizmosEntry.onDrawGizmos += DrawGizmos; // GizmosManager.gizmosEntries.Add(gizmosEntry); // } // public virtual void DrawGizmos (params object[] args) // { // Gizmos.DrawRay(start, end - start); // } // #endif public virtual bool DoIIntersectWithCircle(Circle2D circle) { return((ClosestPoint(circle.center) - circle.center).sqrMagnitude <= circle.radius * circle.radius); }
private bool showLineDiam() { ArrayList usable1Curves = new ArrayList(); Plane pl; double mindist = double.MaxValue; if (tangCurves == null) { return(false); } for (int i = 0; i < tangCurves.Length; ++i) { if (tangCurves[i].GetPlanarState() == PlanarState.Planar) { pl = tangCurves[i].GetPlane(); } else { // Element hat keine Ebene: Eine machen, falls möglich! try { pl = new Plane(tangCurves[i].StartPoint, tangCurves[i].EndPoint, circlePoint); } catch (PlaneException) { break; } } if (Precision.IsPointOnPlane(radiusPoint, pl)) { ICurve2D l2D1 = tangCurves[i].GetProjectedCurve(pl); ICurve2D l2D2 = new Circle2D(pl.Project(circlePoint), 0.0); ICurve2D l2D3 = new Circle2D(pl.Project(radiusPoint), 0.0); GeoPoint2D[] tangentPoints = Curves2D.TangentCircle(l2D1, l2D2, l2D3, pl.Project(objectPoint), pl.Project(circlePoint), pl.Project(radiusPoint)); if (tangentPoints.Length > 0) { // eine gültige Linie ist gefunden usable1Curves.Add(tangCurves[i]); // zur lokalen Liste zufügen for (int l = 0; l < tangentPoints.Length; l += 4) { double dist = Geometry.Dist(tangentPoints[l + 1], pl.Project(objectPoint)) + Geometry.Dist(tangentPoints[l + 2], pl.Project(circlePoint)) + Geometry.Dist(tangentPoints[l + 3], pl.Project(radiusPoint)); if (dist < mindist) { mindist = dist; selected = usable1Curves.Count - 1; // merken, welche Kurven die aktuell benutzten sind // selSol / 6 entspricht div 6, um einige Zeilen tiefer weitere 6 Möglichkeiten auswählen zu können // (/ 4) und (* 4), da pro Lösung vier Punkte geliefert werden int m = (l + 4 * (Math.Abs(selSol) % (tangentPoints.Length / 4))) % tangentPoints.Length; center = tangentPoints[m]; arcRadCalc = Geometry.Dist(tangentPoints[m + 1], center) * 2.0; } } if (mindist < double.MaxValue) { // base.MultiSolution = true; base.MultiSolutionCount = tangentPoints.Length / 4; arc.SetCirclePlaneCenterRadius(pl, pl.ToGlobal(center), arcRad); tangCurves = (ICurve[])usable1Curves.ToArray(typeof(ICurve)); // überschreibt die eigentliche Liste und wird unten an den Sender zurückgeliefert base.ShowActiveObject = true; return(true); } } } } base.ShowActiveObject = false; base.MultiSolutionCount = 0; // base.MultiSolution = false; return(false); }
public void Stirnzahnrad(MainWindow.Außenverzahnung av) { //Profil Erstellen //Nullpunkt double x0 = 0; double y0 = 0; //Hilfsgrößen double Teilkreisradius = av.d / 2; double Hilfskreisradius = Teilkreisradius * 0.94; double Fußkreisradius = Teilkreisradius - (1.25 * av.m); double Kopfkreisradius = Teilkreisradius + av.m; double Verrundungsradius = 0.35 * av.m; double Alpha = 2; double Alpharad = Math.PI * Alpha / 180; double Beta = 140 / av.z; double Betarad = Math.PI * Beta / 180; double Gamma = 90 - (Alpha - Beta); double Gammarad = Math.PI * Gamma / 180; double Totalangel = 360.0 / av.z; double Totalangelrad = Math.PI * Totalangel / 180; //Punkte //Kopfkreis double xKopfkreis = -Kopfkreisradius *Math.Sin(Alpharad); double yKopfkreis = Kopfkreisradius * Math.Cos(Alpharad); //Fußkreis double xFußkreis = -Fußkreisradius *Math.Sin(Betarad); double yFußkreis = Fußkreisradius * Math.Cos(Betarad); //Koordinaten Anfangspunkt Fußkreis double Hilfswinkel = Totalangelrad - Math.Atan(Math.Abs(xFußkreis) / Math.Abs(yFußkreis)); double x_AnfangspunktFußkreis = Fußkreisradius * Math.Sin(Hilfswinkel); double y_AnfangspunktFußkreis = Fußkreisradius * Math.Cos(Hilfswinkel); //Skizze umbenennen und öffnen hsp_catiaProfil.set_Name("Zahnradskizze"); Factory2D catfactory2D1 = hsp_catiaProfil.OpenEdition(); //Nun die Punkte in die Skizze Point2D point_Ursprung = catfactory2D1.CreatePoint(x0, y0); Point2D point_KopfkreisLinks = catfactory2D1.CreatePoint(xKopfkreis, yKopfkreis); Point2D point_FußkreisLinks = catfactory2D1.CreatePoint(xFußkreis, yFußkreis); Point2D point_KopfkreisRechts = catfactory2D1.CreatePoint(-xKopfkreis, yKopfkreis); Point2D point_FußkreisRechts = catfactory2D1.CreatePoint(-xFußkreis, yFußkreis); Point2D point_AnfangspunktLinks = catfactory2D1.CreatePoint(-x_AnfangspunktFußkreis, y_AnfangspunktFußkreis); //Linien Line2D line_FußkreisKopfkreis = catfactory2D1.CreateLine(xFußkreis, yFußkreis, xKopfkreis, yKopfkreis); line_FußkreisKopfkreis.StartPoint = point_FußkreisLinks; line_FußkreisKopfkreis.EndPoint = point_KopfkreisLinks; Line2D line_KopfkreisFußkreis = catfactory2D1.CreateLine(-xKopfkreis, yKopfkreis, -xFußkreis, yFußkreis); line_KopfkreisFußkreis.StartPoint = point_KopfkreisRechts; line_KopfkreisFußkreis.EndPoint = point_FußkreisRechts; //Kreise Circle2D circle_KopfkreisLinksRechts = catfactory2D1.CreateCircle(x0, y0, Kopfkreisradius, 0, Math.PI * 2); circle_KopfkreisLinksRechts.CenterPoint = point_Ursprung; circle_KopfkreisLinksRechts.EndPoint = point_KopfkreisLinks; circle_KopfkreisLinksRechts.StartPoint = point_KopfkreisRechts; Circle2D circle_AnfangFußkreis = catfactory2D1.CreateCircle(x0, x0, Fußkreisradius, 0, Math.PI * 2); circle_AnfangFußkreis.CenterPoint = point_Ursprung; circle_AnfangFußkreis.EndPoint = point_AnfangspunktLinks; circle_AnfangFußkreis.StartPoint = point_FußkreisLinks; hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); //Profilerstellen Ende //Kreismuster ShapeFactory SF = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; HybridShapeFactory HSF = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory; Part myPart = hsp_catiaPart.Part; Factory2D Factory2D2 = hsp_catiaProfil.Factory2D; HybridShapePointCoord Ursprung = HSF.AddNewPointCoord(0, 0, 0); Reference RefUrsprung = myPart.CreateReferenceFromObject(Ursprung); HybridShapeDirection XDir = HSF.AddNewDirectionByCoord(1, 0, 0); Reference RefXDir = myPart.CreateReferenceFromObject(XDir); CircPattern Kreismuster = SF.AddNewSurfacicCircPattern(Factory2D2, 1, 2, 0, 0, 1, 1, RefUrsprung, RefXDir, false, 0, true, false); Kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing; AngularRepartition angularRepartition1 = Kreismuster.AngularRepartition; Angle angle1 = angularRepartition1.AngularSpacing; angle1.Value = Convert.ToDouble(360 / Convert.ToDouble(av.z)); AngularRepartition angularRepartition2 = Kreismuster.AngularRepartition; IntParam intParam1 = angularRepartition2.InstancesCount; intParam1.Value = Convert.ToInt32(av.z) + 1; Reference Ref_Kreismuster = myPart.CreateReferenceFromObject(Kreismuster); HybridShapeAssemble Verbindung = HSF.AddNewJoin(Ref_Kreismuster, Ref_Kreismuster); Reference Ref_Verbindung = myPart.CreateReferenceFromObject(Verbindung); HSF.GSMVisibility(Ref_Verbindung, 0); myPart.Update(); Bodies bodies = myPart.Bodies; Body myBody = bodies.Add(); myBody.set_Name("Zahnrad"); myBody.InsertHybridShape(Verbindung); myPart.Update(); myPart.InWorkObject = myBody; Pad myPad = SF.AddNewPadFromRef(Ref_Verbindung, av.t); myPart.Update(); //Bohrung Reference RefBohrung1 = hsp_catiaPart.Part.CreateReferenceFromBRepName("FSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithInitialFeatureSupport;MonoFond;MFBRepVersion_CXR15)", myPad); Hole catBohrung1 = SF.AddNewHoleFromPoint(0, 0, 0, RefBohrung1, 0); Length catLengthBohrung1 = catBohrung1.Diameter; catLengthBohrung1.Value = Convert.ToDouble(av.d / 2); hsp_catiaPart.Part.Update(); }
public static bool IsCollision(Circle2D circle, Line2D line) { return(IsCollision(line, circle)); }
public static AreaCode Intersect(Circle2D circle2D, Rectangle2D rectangle2D) { throw new NotImplementedException(); }
// This is where the clustering gets done. public void Cluster() { bool Running = true; Circle2D[] previousCentroids = new Circle2D[k]; while (Running) { Array.Copy(centroids, previousCentroids, centroids.Length); // Calculate the distance of the remaining points and // cluster them into the SEC. Based on the minimum-distance principle. for (int i = 0; i < numberOfReferencePoints; i++) { double oldDistance = Int32.MaxValue; double newDistance = 0; int clusterIndex = 0; for (int j = 0; j < k; ++j) { newDistance = distance(points[i].x, centroids[j].p.x, points[i].y, centroids[j].p.y); // If the new distance is smaller than the others we have seen // update the distance and the cluster. if (newDistance <= oldDistance) { oldDistance = newDistance; clusterIndex = j; } } points[i].classification = clusterIndex; // This is the cluster where the point resides clusters[clusterIndex].Add(points[i]); } // Perform the SmallestEnclosingCircle algorithm on our current clusters for (int i = 0; i < k; i++) { SmallestEnclosingCircle(ref clusters[i], ref centroids[i]); } // @Note: // Debugging only System.Console.WriteLine("Smallest Enclosing Cirlce (SEC) Complete: "); System.Console.WriteLine(""); for (int i = 0; i < k; i++) { System.Console.WriteLine(" ({0},{1}), {2}", centroids[i].p.x, centroids[i].p.y, centroids[i].radius); } // Now we need to decide if the algorithm has to run again. // @TODO: // Implement some kind of threshhold definition. // Right now we just see if the previous centroid is the same as the current one, // we could see if the radius decrease is smaller than something.. -bjarke, 21th March 2020. int numberOfEquals = 0; for (int i = 0; i < k; i++) { if (previousCentroids[i].p == centroids[i].p) { numberOfEquals++; } } if (numberOfEquals == k) { // @TODO: // Entering this if-statement, means that the clustering is done. Now we have to insert // each point back into the database, along with their classification (clusterIndex). // Furthermore we will add the centroid center coordinates to the database. UpdateCategories(clusters); Running = false; // SEC is done } // If the algorithm isn't done yet, clear the clusters and redo the clustering. for (int i = 0; i < k; i++) { clusters[i].Clear(); } Array.Copy(centroids, previousCentroids, centroids.Length); } }
public static bool IsCollision(Circle2D circle, Triangle2D tri) { return(IsCollision(tri, circle)); }
public void ErstelleProfilAußenverzahnung(Data dat) { //HilfsRadien double d_r = dat.getTeilkreisdurchmesserZahnrad1() / 2; double hk_r = d_r * 0.94; double df_r = d_r - (1.25 * dat.getModulZahnrad1()); double da_r = d_r + dat.getModulZahnrad1(); double vd_r = 0.35 * dat.getModulZahnrad1(); //HilfsWinkel double alpha = 20; double beta = 90 / dat.getZaehnezahlZahnrad1(); double beta_r = Math.PI * beta / 180; double gamma = 90 - (alpha - beta); double gamma_r = Math.PI * gamma / 180; double ta = 360.0 / dat.getZaehnezahlZahnrad1(); double ta_r = Math.PI * ta / 180; //Nullpunkte double x0 = 0; double y0 = 0; //MittelPunkt EvolventenKreis double MP_EvolventenKreis_x = hk_r * Math.Cos(gamma_r); double MP_EvolventenKreis_y = hk_r * Math.Sin(gamma_r); // SchnittPunkt Evolventenkreis & Teilkreisradius double SP_EvolventenTeilKreis_x = -d_r *Math.Sin(beta_r); double SP_EvolventenTeilKreis_y = d_r * Math.Cos(beta_r); //Evolventenkreis Radius double Evolventenkreis_r = Math.Sqrt(Math.Pow((MP_EvolventenKreis_x - SP_EvolventenTeilKreis_x), 2) + Math.Pow((MP_EvolventenKreis_y - SP_EvolventenTeilKreis_y), 2)); //SchnittPunkt Evolventenkreis & Kopfkreisradius double SP_EvolventenKopfKreis_x = Schnittpunkt_x(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r); double SP_EvolventenKopfKreis_y = Schnittpunkt_y(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r); //MittelPunkt VerrundungsRadius double MP_Verrundung_x = Schnittpunkt_x(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r); double MP_Verrundung_y = Schnittpunkt_y(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r); //SchnittPunkt Evolventenkreis & Verrundungsradius double SP_EvolventeVerrundung_x = Schnittpunkt_x(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); double SP_EvolventeVerrundung_y = Schnittpunkt_y(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); //SchnittPunkt Fußkreis & Verrundungs Radius double SP_FußkreisVerrundungsRadius_x = Schnittpunkt_x(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); double SP_FußkreisVerrundungsRadius_y = Schnittpunkt_y(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r); //StartPunkt Fußkreis Radius double phi = ta_r - Math.Atan(Math.Abs(SP_FußkreisVerrundungsRadius_x) / Math.Abs(SP_FußkreisVerrundungsRadius_y)); double StartPkt_Fußkreis_x = -df_r *Math.Sin(phi); double StartPkt_Fußkreis_y = df_r * Math.Cos(phi); //Skizze umbenennen und öffnen hsp_catiaProfil.set_Name("AußenverzahnungEinzel"); Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition(); //Punkte Point2D catP2D_Ursprung = catFactory2D1.CreatePoint(x0, y0); Point2D catP2D_StartPkt_Fußkreis = catFactory2D1.CreatePoint(StartPkt_Fußkreis_x, StartPkt_Fußkreis_y); Point2D catP2D_SP_FußkreisVerrundungsRadius1 = catFactory2D1.CreatePoint(SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y); Point2D catP2D_SP_FußkreisVerrundungsRadius2 = catFactory2D1.CreatePoint(-SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y); Point2D catP2D_MP_EvolventenKreis1 = catFactory2D1.CreatePoint(MP_EvolventenKreis_x, MP_EvolventenKreis_y); Point2D catP2D_MP_EvolventenKreis2 = catFactory2D1.CreatePoint(-MP_EvolventenKreis_x, MP_EvolventenKreis_y); Point2D catP2D_SP_EvolventenKopfKreis1 = catFactory2D1.CreatePoint(SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y); Point2D catP2D_SP_EvolventenKopfKreis2 = catFactory2D1.CreatePoint(-SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y); Point2D catP2D_MP_Verrundung1 = catFactory2D1.CreatePoint(MP_Verrundung_x, MP_Verrundung_y); Point2D catP2D_MP_Verrundung2 = catFactory2D1.CreatePoint(-MP_Verrundung_x, MP_Verrundung_y); Point2D catP2D_SP_EvolventeVerrundung1 = catFactory2D1.CreatePoint(SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y); Point2D catP2D_SP_EvolventeVerrundung2 = catFactory2D1.CreatePoint(-SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y); //Kreise Circle2D catC2D_Frußkreis = catFactory2D1.CreateCircle(x0, y0, df_r, 0, 0); catC2D_Frußkreis.CenterPoint = catP2D_Ursprung; catC2D_Frußkreis.StartPoint = catP2D_SP_FußkreisVerrundungsRadius1; catC2D_Frußkreis.EndPoint = catP2D_StartPkt_Fußkreis; Circle2D catC2D_Kopfkreis = catFactory2D1.CreateCircle(x0, y0, da_r, 0, 0); catC2D_Kopfkreis.CenterPoint = catP2D_Ursprung; catC2D_Kopfkreis.StartPoint = catP2D_SP_EvolventenKopfKreis2; catC2D_Kopfkreis.EndPoint = catP2D_SP_EvolventenKopfKreis1; Circle2D catC2D_EvolventenKreis1 = catFactory2D1.CreateCircle(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0); catC2D_EvolventenKreis1.CenterPoint = catP2D_MP_EvolventenKreis1; catC2D_EvolventenKreis1.StartPoint = catP2D_SP_EvolventenKopfKreis1; catC2D_EvolventenKreis1.EndPoint = catP2D_SP_EvolventeVerrundung1; Circle2D catC2D_Evolventenkreis2 = catFactory2D1.CreateCircle(-MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0); catC2D_Evolventenkreis2.CenterPoint = catP2D_MP_EvolventenKreis2; catC2D_Evolventenkreis2.StartPoint = catP2D_SP_EvolventeVerrundung2; catC2D_Evolventenkreis2.EndPoint = catP2D_SP_EvolventenKopfKreis2; Circle2D catC2D_VerrundungsKreis1 = catFactory2D1.CreateCircle(MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0); catC2D_VerrundungsKreis1.CenterPoint = catP2D_MP_Verrundung1; catC2D_VerrundungsKreis1.StartPoint = catP2D_SP_FußkreisVerrundungsRadius1; catC2D_VerrundungsKreis1.EndPoint = catP2D_SP_EvolventeVerrundung1; Circle2D catC2D_VerrundungsKreis2 = catFactory2D1.CreateCircle(-MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0); catC2D_VerrundungsKreis2.CenterPoint = catP2D_MP_Verrundung2; catC2D_VerrundungsKreis2.StartPoint = catP2D_SP_EvolventeVerrundung2; catC2D_VerrundungsKreis2.EndPoint = catP2D_SP_FußkreisVerrundungsRadius2; hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); }
public static bool IsCollision(Circle2D circle, Rectangle2D rect) { return(IsCollision(rect, circle)); }
public bool Overlap(Circle2D c) { return((c.Center - Center).SqrMagnitude() < ((c.R + R) * (c.R + R))); }
public void ErzeugeVierkantrohr(Double r_ah, Double r_ih, Double r_ab, Double r_ib) { hsp_catiaProfil.set_Name("VierkantRohr"); Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition(); Point2D catPoint2D1 = catFactory2D1.CreatePoint(r_ab - r_ib, r_ah); Point2D catPoint2D2 = catFactory2D1.CreatePoint(r_ab, r_ah + r_ib - r_ab); Point2D catPoint2D3 = catFactory2D1.CreatePoint(r_ab, 0); Point2D catPoint2D4 = catFactory2D1.CreatePoint(0, 0); Point2D catPoint2D5 = catFactory2D1.CreatePoint((r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2); Point2D catPoint2D6 = catFactory2D1.CreatePoint(r_ib + (r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2); Point2D catPoint2D7 = catFactory2D1.CreatePoint(r_ib + (r_ab - r_ib) / 2, (r_ah - r_ih) / 2); Point2D catPoint2D8 = catFactory2D1.CreatePoint((r_ab - r_ib) / 2, (r_ah - r_ih) / 2); Point2D catPoint2D9 = catFactory2D1.CreatePoint(0, r_ah + r_ib - r_ab); Point2D catPoint2D10 = catFactory2D1.CreatePoint(r_ab - r_ib, r_ah - (r_ab - r_ib)); Point2D catPoint2D11 = catFactory2D1.CreatePoint(r_ib, r_ah); Point2D catPoint2D12 = catFactory2D1.CreatePoint(r_ib, r_ah + r_ib - r_ab); Circle2D catCircle2D1 = catFactory2D1.CreateCircle(r_ab - r_ib, r_ah - (r_ab - r_ib), r_ab - r_ib, r_ab - r_ib, r_ab - r_ib); catCircle2D1.CenterPoint = catPoint2D10; catCircle2D1.StartPoint = catPoint2D1; catCircle2D1.EndPoint = catPoint2D9; Circle2D catCircle2D2 = catFactory2D1.CreateCircle(r_ib, r_ah + r_ib - r_ab, r_ab - r_ib, r_ab - r_ib, r_ab - r_ib); catCircle2D2.CenterPoint = catPoint2D12; catCircle2D2.StartPoint = catPoint2D2; catCircle2D2.EndPoint = catPoint2D11; Line2D catLine2D1 = catFactory2D1.CreateLine(r_ab - r_ib, r_ah, r_ib, r_ah); catLine2D1.StartPoint = catPoint2D1; catLine2D1.EndPoint = catPoint2D11; Line2D catLine2D2 = catFactory2D1.CreateLine(r_ab, r_ah + r_ab - r_ib, r_ab, 0); catLine2D2.StartPoint = catPoint2D2; catLine2D2.EndPoint = catPoint2D3; Line2D catLine2D3 = catFactory2D1.CreateLine(r_ab, 0, 0, 0); catLine2D3.StartPoint = catPoint2D3; catLine2D3.EndPoint = catPoint2D4; Line2D catLine2D4 = catFactory2D1.CreateLine(0, 0, 0, r_ah + r_ib - r_ab); catLine2D4.StartPoint = catPoint2D4; catLine2D4.EndPoint = catPoint2D9; Line2D catLine2D5 = catFactory2D1.CreateLine((r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2, r_ib + (r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2); catLine2D5.StartPoint = catPoint2D5; catLine2D5.EndPoint = catPoint2D6; Line2D catLine2D6 = catFactory2D1.CreateLine(r_ib + (r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2, r_ib + (r_ab - r_ib) / 2, (r_ah - r_ih) / 2); catLine2D6.StartPoint = catPoint2D6; catLine2D6.EndPoint = catPoint2D7; Line2D catLine2D7 = catFactory2D1.CreateLine(r_ib + (r_ab - r_ib) / 2, (r_ah - r_ih) / 2, (r_ab - r_ib) / 2, (r_ah - r_ih) / 2); catLine2D7.StartPoint = catPoint2D7; catLine2D7.EndPoint = catPoint2D8; Line2D catLine2D8 = catFactory2D1.CreateLine((r_ab - r_ib) / 2, (r_ah - r_ih) / 2, (r_ab - r_ib) / 2, r_ih + (r_ah - r_ih) / 2); catLine2D8.StartPoint = catPoint2D8; catLine2D8.EndPoint = catPoint2D5; hsp_catiaProfil.CloseEdition(); hsp_catiaPart.Part.Update(); }
public void Stirnzahnrad(Außenverzahnung av) { //Profil erstellen //Nullpunkt double x0 = 0; double y0 = 0; //Hilfsgrößen double Teilkreisradius = av.d / 2; double Hilfskreisradius = Teilkreisradius * 0.94; double Fußkreisradius = Teilkreisradius - (1.25 * av.m); double Kopfkreisradius = Teilkreisradius + av.m; double Verrundungsradius = 0.35 * av.m; double Alpha = 20; double Beta = 90 / av.z; double Betarad = Math.PI * Beta / 180; double Gamma = 90 - (Alpha - Beta); double Gammarad = Math.PI * Gamma / 180; double Totalangel = 360.0 / av.z; double Totalangelrad = Math.PI + Totalangel / 180; //Punkte erzeugen //Kleiner Kreis double xMittelpunktaufEvol_links = Hilfskreisradius * Math.Cos(Gammarad); double yMittelpunktaufEvol_links = Hilfskreisradius * Math.Sin(Gammarad); //Schnittpunkt auf Evolvente und Teilkreisradius double xPunktaufEvolvente = -Teilkreisradius *Math.Sin(Betarad); double yPunktaufEvolvente = Teilkreisradius * Math.Cos(Betarad); //Evolventenkreis Radius double EvolventenkreisRadius = Math.Sqrt(Math.Pow((xMittelpunktaufEvol_links - xPunktaufEvolvente), 2) + Math.Pow((yMittelpunktaufEvol_links - yPunktaufEvolvente), 2)); //Koordinaten Schnittpunkt Kopfkreis und Evolventenkreis double xEvolventenkopfkreis_links = Schnittpunkt_X(x0, y0, Kopfkreisradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius); double yEvolventenkopfkreis_links = Schnittpunkt_Y(x0, y0, Kopfkreisradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius); //Mittelpunktkoordinaten Verrundung double xMittelpunktVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius + Verrundungsradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius + Verrundungsradius); double yMittelpunktVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius + Verrundungsradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius + Verrundungsradius); //Schnittpunktkoordinaten Verrundung - Evolventenkreis double x_SP_EvolventeVerrundung_links = Schnittpunkt_X(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); double y_SP_EvolventeVerrundung_links = Schnittpunkt_Y(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); //Schnittpunktkoordinaten Verrundung - Fußkreis double x_SP_FußkreisradiusVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); double y_SP_FußkreisradiusVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius); //Koordinaten Anfangspunkt Fußkreis double Hilfswinkel = Totalangelrad - Math.Atan(Math.Abs(x_SP_FußkreisradiusVerrundung_links) / Math.Abs(y_SP_FußkreisradiusVerrundung_links)); double x_AnfangspunktFußkreis = -Fußkreisradius *Math.Sin(Hilfswinkel); double y_AnfangspunktFußkreis = Fußkreisradius * Math.Cos(Hilfswinkel); //Ende //Skizze umbenennen hsp_catiaProfil.set_Name("Zahnrad-Test"); Factory2D catfactory2D1 = hsp_catiaProfil.OpenEdition(); //Punkte in Skizze Point2D point_Ursprung = catfactory2D1.CreatePoint(x0, y0); Point2D pointAnfangFußkreisLinks = catfactory2D1.CreatePoint(x_AnfangspunktFußkreis, y_AnfangspunktFußkreis); Point2D pointFußkreisVerrundungLinks = catfactory2D1.CreatePoint(x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links); Point2D pointFußkreisVerrundungRechts = catfactory2D1.CreatePoint(-x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links); Point2D pointMittelpunktVerrundungLinks = catfactory2D1.CreatePoint(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links); Point2D pointMittelpunktVerrundungRechts = catfactory2D1.CreatePoint(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links); Point2D pointVerrundungEvolventeLinks = catfactory2D1.CreatePoint(x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links); Point2D pointVerrundungEvolventeRechts = catfactory2D1.CreatePoint(-x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links); Point2D pointMittelpunktevolventeLinks = catfactory2D1.CreatePoint(xMittelpunktaufEvol_links, xMittelpunktaufEvol_links); Point2D pointMittelpunktevolventeRechts = catfactory2D1.CreatePoint(-xMittelpunktaufEvol_links, yMittelpunktaufEvol_links); Point2D pointEvolventenKopfkreisLinks = catfactory2D1.CreatePoint(xEvolventenkopfkreis_links, yEvolventenkopfkreis_links); Point2D pointEvolventenKopfkreisRechts = catfactory2D1.CreatePoint(-xEvolventenkopfkreis_links, yEvolventenkopfkreis_links); //Kreise Circle2D KreisFußkreis = catfactory2D1.CreateCircle(x0, y0, Fußkreisradius, 0, Math.PI * 2); KreisFußkreis.CenterPoint = point_Ursprung; KreisFußkreis.StartPoint = pointFußkreisVerrundungLinks; KreisFußkreis.EndPoint = pointAnfangFußkreisLinks; Circle2D KreisVerrundungLinks = catfactory2D1.CreateCircle(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2); KreisVerrundungLinks.CenterPoint = pointMittelpunktVerrundungLinks; KreisVerrundungLinks.StartPoint = pointFußkreisVerrundungLinks; KreisVerrundungLinks.EndPoint = pointVerrundungEvolventeLinks; Circle2D KreisEvolventenkreisLinks = catfactory2D1.CreateCircle(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, 0, Math.PI * 2); KreisEvolventenkreisLinks.CenterPoint = pointMittelpunktevolventeLinks; KreisEvolventenkreisLinks.StartPoint = pointEvolventenKopfkreisLinks; KreisEvolventenkreisLinks.EndPoint = pointVerrundungEvolventeLinks; Circle2D KreisKopfkreis = catfactory2D1.CreateCircle(x0, y0, Kopfkreisradius, 0, Math.PI * 2); KreisKopfkreis.CenterPoint = point_Ursprung; KreisKopfkreis.StartPoint = pointEvolventenKopfkreisRechts; KreisKopfkreis.EndPoint = pointEvolventenKopfkreisLinks; Circle2D KreisEvolventenkreisRechts = catfactory2D1.CreateCircle(-xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, 0, Math.PI * 2); KreisEvolventenkreisRechts.CenterPoint = pointMittelpunktVerrundungRechts; KreisEvolventenkreisRechts.StartPoint = pointVerrundungEvolventeRechts; KreisEvolventenkreisRechts.EndPoint = pointEvolventenKopfkreisRechts; Circle2D KreisVerrundungRechts = catfactory2D1.CreateCircle(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2); KreisVerrundungRechts.CenterPoint = pointMittelpunktVerrundungRechts; KreisVerrundungRechts.StartPoint = pointVerrundungEvolventeRechts; KreisVerrundungRechts.EndPoint = pointFußkreisVerrundungRechts; //Skizzierer schließen hsp_catiaProfil.CloseEdition(); //Aktualisieren hsp_catiaPart.Part.Update(); //Kreismuster erstellen //Deklarierung ShapeFactory SF = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; HybridShapeFactory HSF = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory; Part myPart = hsp_catiaPart.Part; Factory2D Factory2D1 = hsp_catiaProfil.Factory2D; HybridShapePointCoord Ursprung = HSF.AddNewPointCoord(0, 0, 0); Reference RefUrsprung = myPart.CreateReferenceFromObject(Ursprung); HybridShapeDirection XDir = HSF.AddNewDirectionByCoord(1, 0, 0); Reference RefXDir = myPart.CreateReferenceFromObject(XDir); //Kreismuster Daten ausfüllen CircPattern Kreismuster = SF.AddNewSurfacicCircPattern(Factory2D1, 1, 2, 0, 0, 1, 1, RefUrsprung, RefXDir, false, 0, true, false); Kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing; AngularRepartition angularRepartition1 = Kreismuster.AngularRepartition; Angle angle1 = angularRepartition1.AngularSpacing; angle1.Value = Convert.ToDouble(360 / Convert.ToDouble(av.z)); AngularRepartition angularRepartition2 = Kreismuster.AngularRepartition; IntParam intParam1 = angularRepartition2.InstancesCount; intParam1.Value = Convert.ToInt32(av.z) + 1; //geschlossene Kontur herstellen Reference Ref_Kreismuster = myPart.CreateReferenceFromObject(Kreismuster); HybridShapeAssemble Verbindung = HSF.AddNewJoin(Ref_Kreismuster, Ref_Kreismuster); Reference Ref_Verbindung = myPart.CreateReferenceFromObject(Verbindung); HSF.GSMVisibility(Ref_Verbindung, 0); myPart.Update(); Bodies bodies = myPart.Bodies; Body myBody = bodies.Add(); myBody.set_Name("Zahnrad"); myBody.InsertHybridShape(Verbindung); myPart.Update(); }
public static bool Overlap(Box2D box1, Circle2D circle1) { // logic goes here }
public static Point?GetNearest(Circle2D c, Point p) { Ray2D r = new Ray2D(c.Center, p); return(GetNearest(r.Intersection(c), p)); }
public static bool Overlap(Circle2D circle1, Box2D box1) { return(Overlap(box1, circle1)); // No need to rewrite it twice }
private void button1_Click(object sender, EventArgs e) { INFITF.Application catia; //add the reference - catia v5 infiit interface... try { //열려 있는 catia가져오기 catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { //catia 실행하기 catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } MECMOD.PartDocument prtDoc = (MECMOD.PartDocument)catia.Documents.Add("Part"); MECMOD.Part prt = prtDoc.Part; MECMOD.Bodies bdys = prt.Bodies; MECMOD.Body bdy = bdys.Add(); MECMOD.Sketches skts = bdy.Sketches; INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY; Sketch skt1 = skts.Add(xypln); Factory2D fac2d = skt1.OpenEdition(); //fac2d안에서 sketch가 이루어진다. fac2d cketch의 기능을 쓸수있다 Point2D p1 = fac2d.CreatePoint(10, 10); Point2D p2 = fac2d.CreatePoint(10, 30); Point2D p3 = fac2d.CreatePoint(40, 30); Point2D p4 = fac2d.CreatePoint(40, 10); //method를 만들고 line생성 Line2D lin1 = CreateLine(fac2d, p1, p2); Line2D lin2 = CreateLine(fac2d, p2, p3); Line2D lin3 = CreateLine(fac2d, p3, p4); Line2D lin4 = CreateLine(fac2d, p4, p1); CatConstraintType cnstDis = CatConstraintType.catCstTypeDistance; MECMOD.Constraint d1 = createCnst(prt, skt1, cnstDis, lin1, lin3); MECMOD.Constraint d2 = createCnst(prt, skt1, cnstDis, lin2, lin4); MECMOD.Constraint d3 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.HorizontalReference, lin4); MECMOD.Constraint d4 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.VerticalReference, lin1); /* * INFITF.Reference rline1 = prt.CreateReferenceFromGeometry(lin1); * INFITF.Reference rline2 = prt.CreateReferenceFromGeometry(lin2); * INFITF.Reference rline3 = prt.CreateReferenceFromGeometry(lin3); * INFITF.Reference rline4 = prt.CreateReferenceFromGeometry(lin4); * INFITF.Reference rlineH = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.HorizontalReference); * INFITF.Reference rlineV = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.VerticalReference); * * MECMOD.Constraint d1 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3); * MECMOD.Constraint d2 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4); * MECMOD.Constraint d3 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4); * MECMOD.Constraint d4 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1); */ skt1.CloseEdition(); //create a circlr Sketch skt2 = skts.Add(xypln); Factory2D fac2d1 = skt2.OpenEdition(); //fac2d = skt2.OpenEdition(); //이렇게 함녀 된다. INFITF.Reference H = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.HorizontalReference); INFITF.Reference V = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.VerticalReference); Circle2D c = fac2d1.CreateClosedCircle(40, 30, 10); c.CenterPoint = p3; // MECMOD.Constraint orPtH = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance,H,(INFITF.Reference)c); //MECMOD.Constraint orPtV = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, V, (INFITF.Reference)c); MECMOD.Constraint r = skt2.Constraints.AddMonoEltCst(CatConstraintType.catCstTypeRadius, (INFITF.Reference)c); skt2.CloseEdition(); ShapeFactory ShpFac = (ShapeFactory)prt.ShapeFactory; //pad Pad pad = ShpFac.AddNewPad(skt1, 20); //poket Pocket pock = ShpFac.AddNewPocket(skt2, 20); pock.DirectionOrientation = CatPrismOrientation.catRegularOrientation; prt.Update(); }
public static bool Overlap(Circle2D circle1, Circle2D circle2) { // logic goes here }
// Start is called before the first frame update void Start() { var p = new MVector3(1, 0, 0); var aaaaa = new UnityEngine.Quaternion(1, 1, 1, 1); var ptemp = new UnityEngine.Vector3(0.5f, 0, 0); var a = aaaaa * aaaaa * aaaaa * ptemp; Matrix33 rotation = Matrix33.AngleAxis(45, new MVector3(0, 0, 1)); Matrix33 rotation2 = Matrix33.AngleAxis(-45, new MVector3(0, 0, 1)); Debug.Log(p * rotation); Debug.Log(p * rotation * rotation2); Debug.Log(p * (rotation * rotation2)); Debug.Log("-------------------------------------------------------------"); Matrix44 mul = Matrix44.AngleAxisTranslate(45, new MVector3(0, 0, 1), new MVector3(1, 1, 0)); Debug.Log(p * mul); Debug.Log(p * (mul * mul.Inverse())); Debug.Log("-------------------------------------------------------------"); Matrix44 r = Matrix44.AngleAxis(45, new MVector3(0, 0, 1)); Matrix44 t = Matrix44.Translate(new MVector3(1, 1, 0)); Matrix44 composite = r * t; Matrix44 composite2 = t.Inverse() * r.Inverse(); Debug.Log(p * composite); Debug.Log(p * composite * composite2); Debug.Log(p * composite * composite.Inverse()); mMesh = GetComponent <MeshFilter>().mesh; mVertices = mMesh.vertices; mNormals = mMesh.normals; var temp = new Matrix33(10, 0, 0, 0, 10, 0, 0, 0, 1); var temp2 = temp.Inverse(); var tempInverse = new Matrix33(0, 0, 0, 0, 0, 0, -3, -4, 1); p = new MVector3(0, 0, 1); p = p * temp; p.z = 1; p = p * tempInverse; var t3 = temp * tempInverse; t = Matrix44.Translate(new MVector3(3, 4, 5)); r = Matrix44.AngleAxis(30, new MVector3(0, 1, 0)); var s = Matrix44.Scale(new MVector3(0.5f, 2, 1)); p = new MVector3(1, 1, 1); var p1 = p * s * r * t; p = p1 * t.Inverse() * r.Inverse() * s.Inverse(); var ray2d1 = new MRay(new MVector3(1, -1, 0), new MVector3(1, 1, 0)); var aaa = ray2d1.GetNearestPos(new MVector3(1, 1, 0)); float aaaa = 1; var plane1 = new MPlane(new MVector3(1, 1, 1), 1); var pos1 = plane1.GetNearestPos(new MVector3(5, 5, 5)); var pos2 = plane1.GetNearestPos(new MVector3(-5, -5, -5)); var plane2 = new MPlane(new MVector3(-1, -1, -1), -1); var pos3 = plane2.GetNearestPos(new MVector3(5, 5, 5)); var pos4 = plane2.GetNearestPos(new MVector3(-5, -5, -5)); var plane3 = new MPlane(new MVector3(-1, -1, -1), 1); var pos5 = plane3.GetNearestPos(new MVector3(5, 5, 5)); var pos6 = plane3.GetNearestPos(new MVector3(-5, -5, -5)); // 三角形测试 pos1 = new MVector3(0, 0, 3); pos2 = new MVector3(0, 1, 3); pos3 = new MVector3(1, 0, 3); var triangle1 = new Triangle(pos1, pos2, pos3); var result = triangle1.InclusionPos(pos1); var targetPos = MVector3.zero; result = triangle1.InclusionPos(pos2); result = triangle1.GetGravityPos(pos2, out targetPos); result = triangle1.InclusionPos(pos3); result = triangle1.GetGravityPos(pos3, out targetPos); float dis = 0; result = triangle1.Raycast(new MRay(new MVector3(0.4f, 0.6f, -0.2567f), new MVector3(0, 0, 1)), out dis); pos4 = new MVector3(0.5f, 0.5f, 3); result = triangle1.InclusionPos(pos4); result = triangle1.GetGravityPos(pos4, out targetPos); result = triangle1.GetGravityPos(pos4, out targetPos); pos4 = new MVector3(0.4f, 0.4f, 0.1f); result = triangle1.InclusionPos(pos4); result = triangle1.GetGravityPos(pos4, out targetPos); result = triangle1.GetGravityPos(pos4, out targetPos); pos4 = new MVector3(0.6f, 0.6f, 3); result = triangle1.InclusionPos(pos4); result = triangle1.GetGravityPos(pos4, out targetPos); result = triangle1.GetGravityPos(pos4, out targetPos); pos4 = new MVector3(-0.1f, -0.1f, 3); result = triangle1.InclusionPos(pos4); result = triangle1.GetGravityPos(pos4, out targetPos); result = triangle1.GetGravityPos(pos4, out targetPos); result = triangle1.InclusionPos(pos3); result = triangle1.GetGravityPos(pos3, out targetPos); result = triangle1.GetGravityPos(pos3, out targetPos); var tempxxx = 0; Circle2D c1 = new Circle2D(MVector2.zero, 1); var t1 = c1.GetNearestPos(new MVector2(2, 0)); var t2 = c1.GetNearestPos(new MVector2(0.5f, 0)); tempxxx = 0; var r1 = new MRay2D(new MVector2(1, 1), new MVector2(0, -1)); var r2 = new MRay2D(new MVector2(10, 0), new MVector2(1, 0)); MVector2 r12v; bool r12r = r1.Interact(r2, out r12v); float c10, c11; bool r10 = c1.IntersectRay(r1, out c10, out c11); tempxxx = 0; }
public static void CreateCylinder(double thickness, double radius) { oCurrentSketch = oPartBody.Sketches.Add ( oPlaneYZ ); Factory2D oFactory2D = (Factory2D)oCurrentSketch.OpenEdition(); oCurrentCircle1 = oFactory2D.CreateClosedCircle (iCenterX, iCenterY, radius); oCurrentSketch.CloseEdition(); ShapeFactory oShapeFactory = (ShapeFactory)oPart; Pad oPad = oShapeFactory.AddNewPad ( oCurrentSketch, thickness + iCurrentLevel ); oPad.SecondLimit.Dimension.Value = iCurrentLevel*-1; iCurrentLevel = iCurrentLevel + thickness; }