/// <summary> /// Method to constrcut the Plane 1 and Point A /// </summary> private void ConstructPlaneRedPlane1AndPointA() { ///Constructing Plane1 from Bottom Wishbone Points and the Top Front Pick-Up Point ///<remarks>Right now selection of these 3 points is random. Need to figure out how to select them properly</remarks> Plane1 = new Plane(BottomFrontInboard.Position.Clone() as Point3D, BottomRearInboard.Position.Clone() as Point3D, TopFrontInboard.Position.Clone() as Point3D); ///<summary>Creating a <see cref="Segment3D"/> using the <see cref="SteeringAxis"/> so that I can use the <see cref="Segment3D.IntersectWith(Plane, bool, out Point3D)"/> to compute the intersection of the Plane1 and Steering Axis</summary> Segment3D SteeringAxisSegment = new Segment3D(SteeringAxis.StartPoint.Clone() as Point3D, SteeringAxis.EndPoint.Clone() as Point3D); ///<summary>Computing the Intersection of the <see cref="SteeringAxis"/> with the <see cref="Plane1"/> which results in <see cref="PointA"/></summary> SteeringAxisSegment.IntersectWith(Plane1, true, out PointA); ///<summary>Determining the whether the <see cref="PointA"/> is above or below the Wishbones</summary> if (PointA.Y > UBJ_Rear.Position.Y && PointA.Y > TopFrontInboard.Position.Y && PointA.Y > TopRearInboard.Position.Y) { PointAPos = PositionOfPointA.AboveWishbones; } else if (PointA.Y < LBJ_Rear.Position.Y && PointA.Y < BottomFrontInboard.Position.Y && PointA.Y < BottomRearInboard.Position.Y) { PointAPos = PositionOfPointA.BelowWishbones; } ///<summary>Adding them to the VIewport as a Planar Entity</summary> PlanarEntity Plane1_Ent = new PlanarEntity(Plane1); Joint PointA_Ent = new Joint(PointA, 10, 2); PointA_Ent.Color = Color.AntiqueWhite; //cad1.viewportLayout1.Entities.AddRange(new Entity[] { Plane1_Ent, PointA_Ent }); }
public static void TerrainTriangulation(Model model) { MainWindow.SetBackgroundStyleAndColor(model); int sideCount = 100; int len = sideCount * sideCount; Point3D[] pts = new Point3D[len]; Random rand = new Random(3); for (int j = 0; j < sideCount; j++) { for (int i = 0; i < sideCount; i++) { double x = rand.NextDouble() * sideCount; double y = rand.NextDouble() * sideCount; double z = 0; double _x = x / 2 - 15; double _y = y / 2 - 15; double den = Math.Sqrt(_x * _x + _y * _y); if (den != 0) { z = 10 * Math.Sin(Math.Sqrt(_x * _x + _y * _y)) / den; } int R = (int)(255 * (z + 2) / 12); int B = (int)(2.55 * y); Utility.LimitRange <int>(0, ref R, 255); Utility.LimitRange <int>(0, ref B, 255); PointRGB pt = new PointRGB(x, y, z, (byte)R, 255, (byte)B); pts[i + j * sideCount] = pt; } } Mesh m = UtilityEx.Triangulate(pts); model.Entities.Add(m); Plane pln = new Plane(new Point3D(0, 20, 20), new Vector3D(20, -30, 10)); PlanarEntity pe = new PlanarEntity(pln, 25); model.Entities.Add(pe, Color.Magenta); ICurve[] curves = m.Section(pln, 0); foreach (Entity ent in curves) { model.Entities.Add(ent); } }
/// <summary> /// Method to Construct the <see cref="PlaneB"/> and <see cref="PointB"/> /// </summary> private void ConstructPlaneBAndPointB() { ///<summary>Calculating the angle between the <see cref="PlaneRED"/> and the <see cref="Bisector2"/></summary> Angle Angle_Bis2_PlaneRED = SetupChangeDatabase.AngleInRequiredView(Custom3DGeometry.GetMathNetVector3D(LineForAngle_PlaneRED), Custom3DGeometry.GetMathNetVector3D(Bisector2), Custom3DGeometry.GetMathNetVector3D(new Line(InstantAxis.StartPoint, InstantAxis.EndPoint))); ///<summary>Calculating the angle between the <see cref="PlaneRED2"/> and the <see cref="Bisector2"/></summary> Angle Angle_Bis2_PlaneRED2 = SetupChangeDatabase.AngleInRequiredView(Custom3DGeometry.GetMathNetVector3D(LineForAngle_PlaneRed2), Custom3DGeometry.GetMathNetVector3D(Bisector2), Custom3DGeometry.GetMathNetVector3D(new Line(InstantAxis.StartPoint, InstantAxis.EndPoint))); ///<summary>Depending on which of the above 2 angles is smaller the final angle called <see cref="Angle_Bis2_Final_PlaneREDs"/> is assigned</summary> if (Math.Abs(Angle_Bis2_PlaneRED.Degrees) < Math.Abs(Angle_Bis1_PlaneRED.Degrees)) { Angle_Bis2_Final_PlaneREDs = Angle_Bis2_PlaneRED; PlaneToConstructPlaneB = PlaneRED.Clone() as Plane; } else { Angle_Bis2_Final_PlaneREDs = Angle_Bis2_PlaneRED2; PlaneToConstructPlaneB = PlaneRED2.Clone() as Plane; } ///<summary>Rotating the <see cref="PlaneToConstructPlaneB"/> by an amount equal to twice the final angle calculated above</summary> PlaneToConstructPlaneB.Rotate(-Angle_Bis2_Final_PlaneREDs.Radians * 2, new Vector3D(InstantAxis.StartPoint, InstantAxis.EndPoint), InstantAxis.MidPoint); ///<summary>Depending upon the Position of <see cref="PointA"/> the <see cref="SegmentForPointB"/> is decided</summary> if (PointAPos == PositionOfPointA.AboveWishbones) { SegmentForPointB = new Segment3D(LBJ_Rear.Position, ToeLinkupright.Position); } else if (PointAPos == PositionOfPointA.BelowWishbones) { SegmentForPointB = new Segment3D(UBJ_Rear.Position, ToeLinkupright.Position); } ///<summary>Computing the Intersection between the <see cref="SegmentForPointB"/> and the <see cref="PlaneToConstructPlaneB"/> which results in the <see cref="PointB"/></summary> SegmentForPointB.IntersectWith(PlaneToConstructPlaneB, true, out PointB); ///<summary>Depending upon whether the <<see cref="PointA"/> is above or below the Wishbones, the Points to draw <see cref="PlaneB"/> (apart from <see cref="PointB"/>!!!) are chosen</summary> if (PointAPos == PositionOfPointA.AboveWishbones) { PlaneB = new Plane(BottomRearInboard.Position, BottomFrontInboard.Position, PointB); } else if (PointAPos == PositionOfPointA.BelowWishbones) { PlaneB = new Plane(TopRearInboard.Position, TopFrontInboard.Position, PointB); } PlanarEntity PlaneB_Ent = new PlanarEntity(PlaneB); Joint PointB_Ent = new Joint(PointB, 5, 2); PointB_Ent.Color = Color.AntiqueWhite; //cad1.viewportLayout1.Entities.AddRange(new Entity[] { PlaneB_Ent, PointB_Ent }); }
/// <summary> /// Mthod to construct the <see cref="PlaneSTEERING"/> /// </summary> private void ConstructPlaneSTEERING() { PlaneSTEERING = new Plane(InstantAxis.StartPoint.Clone() as Point3D, InstantAxis.EndPoint.Clone() as Point3D, ToeLinkupright.Position.Clone() as Point3D); if (ToeLinkupright.Position.Y > Bisector1.MidPoint.Y && ToeLinkupright.Position.Y > Bisector1.EndPoint.Y) { ToeLinkUprightPos = ToeLinkUprightPosition.AboveBisector1; LinkagePair = BobillierPair.BottomWishboneAndSteering; } else if (ToeLinkupright.Position.Y < Bisector1.MidPoint.Y && ToeLinkupright.Position.Y < Bisector1.EndPoint.Y) { ToeLinkUprightPos = ToeLinkUprightPosition.BelowBisector1; LinkagePair = BobillierPair.TopWishboneAndSteering; } PlanarEntity PlaneSTEERING_Ent = new PlanarEntity(PlaneSTEERING); //cad1.viewportLayout1.Entities.Add(PlaneSTEERING_Ent); }
/// <summary> /// Method to construct the <see cref="PlaneRED"/> and the <see cref="PlaneRED2"/> /// </summary> private void ConstructPlaneREDs() { ///<summary>Constructing the <see cref="PlaneRED"/> using the <see cref="InstantAxis"/> and the <see cref="PointA"/></summary> PlaneRED = new Plane(InstantAxis.StartPoint.Clone() as Point3D, InstantAxis.EndPoint.Clone() as Point3D, PointA.Clone() as Point3D); ///<summary>Constructing the Line of the <see cref=PlaneRED"/> needed for the angle</summary> LineForAngle_PlaneRED = new Line(InstantAxis.MidPoint.Clone() as Point3D, PointA.Clone() as Point3D); ///<summary>Computing the <see cref="Angle"/> between the <see cref="PlaneRED"/> and the <see cref="Bisector1"/></summary> Angle_Bis1_PlaneRED = SetupChangeDatabase.AngleInRequiredView(Custom3DGeometry.GetMathNetVector3D(LineForAngle_PlaneRED), Custom3DGeometry.GetMathNetVector3D(Bisector1), Custom3DGeometry.GetMathNetVector3D(new Line(InstantAxis.StartPoint, InstantAxis.EndPoint))); ///<summary>Cloning <see cref="PlaneRED"/> onto <see cref="PlaneRED2"/> and creating its line</summary> PlaneRED2 = PlaneRED.Clone() as Plane; LineForAngle_PlaneRed2 = LineForAngle_PlaneRED.Clone() as Line; ///<summary>Rotating the <see cref="PlaneRED2"/> and its <see cref="LineForAngle_PlaneRed2"/> by an amount equal to twice the Angle b/w <see cref="Bisector1"/> and <see cref="PlaneRED"/></summary> PlaneRED2.Rotate(-Angle_Bis1_PlaneRED.Radians * 2, new Vector3D(InstantAxis.StartPoint.Clone() as Point3D, InstantAxis.EndPoint.Clone() as Point3D), InstantAxis.MidPoint); LineForAngle_PlaneRed2.Rotate(-Angle_Bis1_PlaneRED.Radians * 2, new Vector3D(InstantAxis.StartPoint.Clone() as Point3D, InstantAxis.EndPoint.Clone() as Point3D), InstantAxis.StartPoint); PlanarEntity PlaneRED_Ent = new PlanarEntity(PlaneRED); PlanarEntity PlaneRED2_Ent = new PlanarEntity(PlaneRED2); //cad1.viewportLayout1.Entities.AddRange(new Entity[] { PlaneRED_Ent, PlaneRED2_Ent }); }
public static PlanarEntity getPlane() { return(PlanarEntity.Create(IntPtr.Zero, true)); }
public bool AreEqual(Entity ent1, Entity ent2) { if (ent1 is CompositeCurve) { CompositeCurve cc1 = (CompositeCurve)ent1; CompositeCurve cc2 = (CompositeCurve)ent2; if (cc1.CurveList.Count == cc2.CurveList.Count) { int equalCurvesInListCount = 0; foreach (Entity entC in cc1.CurveList) { foreach (Entity entC2 in cc2.CurveList) { if (entC.GetType() == entC2.GetType()) { if (CompareIfEqual(entC, entC2)) { equalCurvesInListCount++; break; } } } } if (cc1.CurveList.Count == equalCurvesInListCount) { return(true); } } } else if (ent1 is LinearPath) { LinearPath lp1 = (LinearPath)ent1; LinearPath lp2 = (LinearPath)ent2; if (lp1.Vertices.Length == lp2.Vertices.Length) { for (int i = 0; i < lp1.Vertices.Length; i++) { if (!(lp1.Vertices[i] == lp2.Vertices[i])) { return(false); } } return(true); } } else if (ent1 is PlanarEntity) { PlanarEntity pe1 = (PlanarEntity)ent1; PlanarEntity pe2 = (PlanarEntity)ent2; if ( pe1.Plane.AxisZ == pe2.Plane.AxisZ && pe1.Plane.AxisX == pe2.Plane.AxisX ) { if (ent1 is Arc) { Arc arc1 = (Arc)ent1; Arc arc2 = (Arc)ent2; if ( arc1.Center == arc2.Center && arc1.Radius == arc2.Radius && arc1.Domain.Min == arc2.Domain.Min && arc1.Domain.Max == arc2.Domain.Max ) { return(true); } } else if (ent1 is Circle) { Circle c1 = (Circle)ent1; Circle c2 = (Circle)ent2; if ( c1.Center == c2.Center && c1.Radius == c2.Radius ) { return(true); } } else if (ent1 is EllipticalArc) { EllipticalArc e1 = (EllipticalArc)ent1; EllipticalArc e2 = (EllipticalArc)ent2; if ( e1.Center == e2.Center && e1.RadiusX == e2.RadiusX && e1.RadiusY == e2.RadiusY && e1.Domain.Low == e2.Domain.Low && e1.Domain.High == e2.Domain.High ) { return(true); } } else if (ent1 is Ellipse) { Ellipse e1 = (Ellipse)ent1; Ellipse e2 = (Ellipse)ent2; if ( e1.Center == e2.Center && e1.RadiusX == e2.RadiusX && e1.RadiusY == e2.RadiusY ) { return(true); } } else if (ent1 is Text) { if (ent1 is Dimension) { Dimension dim1 = (Dimension)ent1; Dimension dim2 = (Dimension)ent2; if ( dim1.InsertionPoint == dim2.InsertionPoint && dim1.DimLinePosition == dim2.DimLinePosition ) { if (ent1 is AngularDim) { AngularDim ad1 = (AngularDim)ent1; AngularDim ad2 = (AngularDim)ent2; if ( ad1.ExtLine1 == ad2.ExtLine1 && ad1.ExtLine2 == ad2.ExtLine2 && ad1.StartAngle == ad2.StartAngle && ad1.EndAngle == ad2.EndAngle && ad1.Radius == ad2.Radius ) { return(true); } } else if (ent1 is LinearDim) { LinearDim ld1 = (LinearDim)ent1; LinearDim ld2 = (LinearDim)ent2; if ( ld1.ExtLine1 == ld2.ExtLine1 && ld1.ExtLine2 == ld2.ExtLine2 ) { return(true); } } else if (ent1 is DiametricDim) { DiametricDim dd1 = (DiametricDim)ent1; DiametricDim dd2 = (DiametricDim)ent2; if ( dd1.Distance == dd2.Distance && dd1.Radius == dd2.Radius && dd1.CenterMarkSize == dd2.CenterMarkSize ) { return(true); } } else if (ent1 is RadialDim) { RadialDim rd1 = (RadialDim)ent1; RadialDim rd2 = (RadialDim)ent2; if ( rd1.Radius == rd2.Radius && rd1.CenterMarkSize == rd2.CenterMarkSize ) { return(true); } } else if (ent1 is OrdinateDim) { OrdinateDim od1 = (OrdinateDim)ent1; OrdinateDim od2 = (OrdinateDim)ent2; if ( od1.DefiningPoint == od2.DefiningPoint && od1.Origin == od2.Origin && od1.LeaderEndPoint == od2.LeaderEndPoint ) { return(true); } } else { Console.Write("Type " + ent1.GetType() + " not implemented."); return(true); } } } else if (ent1 is devDept.Eyeshot.Entities.Attribute) { devDept.Eyeshot.Entities.Attribute att1 = (devDept.Eyeshot.Entities.Attribute)ent1; devDept.Eyeshot.Entities.Attribute att2 = (devDept.Eyeshot.Entities.Attribute)ent2; if ( att1.Value == att2.Value && att1.InsertionPoint == att2.InsertionPoint ) { return(true); } } else { Text tx1 = (Text)ent1; Text tx2 = (Text)ent2; if ( tx1.InsertionPoint == tx2.InsertionPoint && tx1.TextString == tx2.TextString && tx1.StyleName == tx2.StyleName && tx1.WidthFactor == tx2.WidthFactor && tx1.Height == tx2.Height ) { return(true); } } } else { Console.Write("Type " + ent1.GetType() + " not implemented."); return(true); } } } else if (ent1 is Line) { Line line1 = (Line)ent1; Line line2 = (Line)ent2; if ( line1.StartPoint == line2.StartPoint && line1.EndPoint == line2.EndPoint ) { return(true); } } else if (ent1 is devDept.Eyeshot.Entities.Point) { devDept.Eyeshot.Entities.Point point1 = (devDept.Eyeshot.Entities.Point)ent1; devDept.Eyeshot.Entities.Point point2 = (devDept.Eyeshot.Entities.Point)ent2; if ( point1.Position == point2.Position ) { return(true); } } #if NURBS else if (ent1 is Curve) { Curve cu1 = (Curve)ent1; Curve cu2 = (Curve)ent2; if ( cu1.ControlPoints.Length == cu2.ControlPoints.Length && cu1.KnotVector.Length == cu2.KnotVector.Length && cu1.Degree == cu2.Degree ) { for (int k = 0; k < cu1.ControlPoints.Length; k++) { if (cu1.ControlPoints[k] != cu2.ControlPoints[k]) { return(false); } } for (int k = 0; k < cu1.KnotVector.Length; k++) { if (cu1.KnotVector[k] != cu2.KnotVector[k]) { return(false); } } return(true); } } #endif else { Console.Write("Type " + ent1.GetType() + " not implemented."); return(true); } return(false); }
public static Point2d to2d(this Point3d point, PlanarEntity pl) { return(point.Convert2d(pl)); }