3 Replies Latest reply on Nov 14, 2013 11:31 AM by Oleg Bezyaev


    Oleg Bezyaev

      Is there a way to determine at what point the line intersects the curve of any type(line, arc, circle, spline)?

      Maybe do it with some tessellation?

        • Re: IntersectCurve
          Oleg Bezyaev

          I invented like this:


          ICurve anyCurve = myEdje.GetCurve();

          ICurve lineCurve = CreateLine(rootSwApp.IGetModeler(), new double[]

          { myCenterPlane.ArrayData[0], myCenterPlane.ArrayData[1], myCenterPlane.ArrayData[2] },

             new double[] { vectorX.ArrayData[0] + myCenterPlane.ArrayData[0],

                            vectorX.ArrayData[1] + myCenterPlane.ArrayData[1],

                                                    vectorX.ArrayData[2] + myCenterPlane.ArrayData[2] });

          double[] lineCurvePoints = lineCurve.Evaluate2(0, 2);

          double[] anyCurvePoints = anyCurve.Evaluate2(0, 2);

          double[] firstStart = new double[]{lineCurvePoints[0],lineCurvePoints[1],lineCurvePoints[2]};

          double[] firstEnd = new double[] { lineCurvePoints[3], lineCurvePoints[4], lineCurvePoints[5] };

          double[] secondStart = new double[] { anyCurvePoints[0], anyCurvePoints[1], anyCurvePoints[2] };

          double[] secondEnd = new double[] { anyCurvePoints[3], anyCurvePoints[4], anyCurvePoints[5] };

          double[] res = lineCurve.IntersectCurve


              new double[] { firstStart[0], firstStart[1], firstStart[2] },

              new double[] { firstEnd[0], firstEnd[1], firstEnd[2] },

              new double[] { secondStart[0], secondStart[1], secondStart[1] },

              new double[] { secondEnd[0], secondEnd[1], secondEnd[2] });

          But the approximation turned out terrible.

            • Re: IntersectCurve
              Mohammed Elkalakhi

              Use this to get your start and end points,


              It is a VB NET sample !!


              If TypeOf swSegment Is SketchSegment Then


                          Dim swSketchSegment As SketchSegment = CType(swSegment, SketchSegment)

                          swCurve = swSketchSegment.GetCurve

                          Dim swSkPoint1 As SketchPoint = Nothing

                          Dim swSkPoint2 As SketchPoint = Nothing

                          Select Case swSketchSegment.GetType

                              Case swSketchSegments_e.swSketchLINE

                                  Dim swSkLine As SketchLine = swSegment

                                  swSkPoint1 = swSkLine.GetStartPoint2()

                                  swSkPoint2 = swSkLine.GetEndPoint2()

                              Case swSketchSegments_e.swSketchARC

                                  Dim swSkArc As SketchArc = swSegment

                                  swSkPoint1 = swSkArc.GetStartPoint2()

                                  swSkPoint2 = swSkArc.GetEndPoint2()

                              Case swSketchSegments_e.swSketchSPLINE

                                  Dim swSkSpline As SketchSpline = swSegment

                                  Dim swSkPoints As System.Array = swSkSpline.GetPoints2

                                  swSkPoint1 = swSkPoints(0)

                                  swSkPoint2 = swSkPoints(swSkPoints.Length - 1)

                              Case swSketchSegments_e.swSketchELLIPSE

                                  Dim swSkEllipse As SketchEllipse = swSegment

                                  swSkPoint1 = swSkEllipse.GetStartPoint2()

                                  swSkPoint2 = swSkEllipse.GetEndPoint2()

                              Case swSketchSegments_e.swSketchPARABOLA

                                  Dim swParabola As SketchParabola = swSegment

                                  swSkPoint1 = swParabola.GetStartPoint2()

                                  swSkPoint2 = swParabola.GetEndPoint2()

                          End Select


                          dbPoint1 = {swSkPoint1.X, swSkPoint1.Y, swSkPoint1.Z}

                          dbPoint2 = {swSkPoint2.X, swSkPoint2.Y, swSkPoint2.Z}


                      ElseIf TypeOf swSegment Is Edge Then


                          Dim swEdge As Edge = CType(swSegment, Edge)

                          swCurve = swEdge.GetCurve

                          Dim swCurveParamData As CurveParamData = swEdge.GetCurveParams3

                          Dim swVertex1() As Double = swCurveParamData.StartPoint

                          Dim swVertex2() As Double = swCurveParamData.EndPoint


                          dbPoint1 = {swVertex1(0), swVertex1(1), swVertex1(2)}

                          dbPoint2 = {swVertex2(0), swVertex2(1), swVertex2(2)}


                      End If