Three-dimensional central inflection point between two 3d points

Three-dimensional central inflection point between two 3d points

Kélcyo
Advocate Advocate
486 Views
5 Replies
Message 1 of 6

Three-dimensional central inflection point between two 3d points

Kélcyo
Advocate
Advocate

How can I get the three-dimensional central inflection point between two 3d points, and that the first tangent passes through a 3d vector with origin at the first point.
Does anyone have a function that performs this calculation, or something similar?

 

Any idea @_gile@norman.yuan 

0 Likes
Accepted solutions (1)
487 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

As described that does not make sense for me, it looks like there're missing data to define the curve on which the inflection point is.

Could you provide some drawing, please.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

Kélcyo
Advocate
Advocate

Yes, here is an illustrative image and a file with the same three-dimensional information.
An observation is that the calculated point must always be in the plane that passes through the provided vector and point 2. That is, the vector can be rotated 360 degrees, but it will always have its origin at point 1.

Modelo.png

0 Likes
Message 4 of 6

_gile
Consultant
Consultant

Here's a way.

        static Point3d GetCentralPoint(Point3d ptA, Point3d ptB, Vector3d direction)
        {
            var normal = direction.CrossProduct(ptA.GetVectorTo(ptB));
            if (normal.Length == 0.0)
                return ptA + ptA.GetVectorTo(ptB) / 2.0;
            var plane = new Plane(ptA, normal);
            var ptA2d = ptA.Convert2d(plane);
            var ptB2d = ptB.Convert2d(plane);
            var segmentAB = new LineSegment2d(ptA2d, ptB2d);
            var axis = new Line2d(segmentAB.MidPoint, segmentAB.Direction.GetPerpendicularVector());
            var dirA = direction.Convert2d(plane);
            var dirB = dirA.TransformBy(Matrix2d.Mirroring(axis));
            var ptCen2d = new Line2d(ptA2d, dirA).IntersectWith(new Line2d(ptB2d, dirB))[0];
            return new Point3d(ptCen2d.X, ptCen2d.Y, 0.0).TransformBy(Matrix3d.PlaneToWorld(plane));
        }

 

A testing command

        [CommandMethod("TEST")]
        public void Test()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var ppo = new PromptPointOptions("\nSpecify first point: ");
            var ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            var ptA = ppr.Value;

            ppo.Message = "\nSpecify second point: ";
            ppo.UseBasePoint = true;
            ppo.BasePoint = ptA;
            ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            var ptB = ppr.Value;

            ppo.Message = "\nSpecify direction: ";
            ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            var dir = ptA.GetVectorTo(ppr.Value);

            var ptCen = GetCentralPoint(ptA, ptB, dir);
            ed.Command("_point", ptCen);
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 6

_gile
Consultant
Consultant
Accepted solution

Another way:

 

        static Point3d GetCentralPoint(Point3d ptA, Point3d ptB, Vector3d direction)
        {
            if (ptA.GetVectorTo(ptB).IsParallelTo(direction))
                return ptA + ptA.GetVectorTo(ptB) * 0.5;
            var segmentAB = new LineSegment3d(ptA, ptB);
            var plane = new Plane(segmentAB.MidPoint, segmentAB.Direction);
            var lineA = new Line3d(ptA, direction);
            var lineB = (Line3d)lineA.Clone();
            lineB.TransformBy(Matrix3d.Mirroring(plane));
            return lineA.IntersectWith(lineB)[0];
        }

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6

Kélcyo
Advocate
Advocate
Perfect, in a quick test, I detected that the first option contains an exception when the points are aligned in the same elevation (Z). However, the second option does not cause the same error, and as far as I evaluated there were no errors found... Thanks
0 Likes