.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GetClosestPointTo Curve Extension

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
SRSDS
621 Views, 2 Replies

GetClosestPointTo Curve Extension

SRSDS
Advisor
Advisor

Can someone suggest the cleanest way to find the closest point to the extension of a curve.

Given that I know which end the extension is from.

 

If the closest point is the curve StartPoint I can easily get position on the curve at a distance of 1 from the StartPoint.

Create a line to find the extension.

 Dim EP As Point3d = TransformPointToLine(MousePosition, curve.StartPoint, curve.GetPointAtDist(1))

Function TransformPointToLine(ByVal apoint As Point3d, ByVal startpoint As Point3d, ByVal EndPoint As Point3d) As Point3d
    Using myline As Line = New Line(startpoint, EndPoint)
         Return myline.GetClosestPointTo(apoint, True)
    End Using
End Function

 

Can I do the same for the end point? Ie Find a point 1mm back from the curve EndPoint?

 

 

 

 

0 Likes

GetClosestPointTo Curve Extension

Can someone suggest the cleanest way to find the closest point to the extension of a curve.

Given that I know which end the extension is from.

 

If the closest point is the curve StartPoint I can easily get position on the curve at a distance of 1 from the StartPoint.

Create a line to find the extension.

 Dim EP As Point3d = TransformPointToLine(MousePosition, curve.StartPoint, curve.GetPointAtDist(1))

Function TransformPointToLine(ByVal apoint As Point3d, ByVal startpoint As Point3d, ByVal EndPoint As Point3d) As Point3d
    Using myline As Line = New Line(startpoint, EndPoint)
         Return myline.GetClosestPointTo(apoint, True)
    End Using
End Function

 

Can I do the same for the end point? Ie Find a point 1mm back from the curve EndPoint?

 

 

 

 

2 REPLIES 2
Message 2 of 3
_gile
in reply to: SRSDS

_gile
Mentor
Mentor

Hi,

 

For geometric computations you should use the geometric objects from the Autodesk.AutoCAD.Geometry namespace, they are much more lighter than entities and do not need to be explicitly disposed.

 

        static Point3d TransformPointToLine(Point3d point, Point3d startPoint, Point3d endPoint)
        {
            return new Line3d(startPoint, endPoint).GetClosestPointTo(point).Point;
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Hi,

 

For geometric computations you should use the geometric objects from the Autodesk.AutoCAD.Geometry namespace, they are much more lighter than entities and do not need to be explicitly disposed.

 

        static Point3d TransformPointToLine(Point3d point, Point3d startPoint, Point3d endPoint)
        {
            return new Line3d(startPoint, endPoint).GetClosestPointTo(point).Point;
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
_gile
in reply to: _gile

_gile
Mentor
Mentor
Accepted solution

I didn't read your request enough attentively.

This should be closer to my understanding of your issue.

 

        static Point3d GetClosestPointToStartTangent(Curve curve, Point3d point)
        {
            var line = new Line3d(curve.StartPoint, curve.GetFirstDerivative(curve.StartPoint));
            return line.GetClosestPointTo(point).Point;
        }

        static Point3d GetClosestPointToEndtTangent(Curve curve, Point3d point)
        {
            var line = new Line3d(curve.EndPoint, curve.GetFirstDerivative(curve.EndPoint));
            return line.GetClosestPointTo(point).Point;
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

I didn't read your request enough attentively.

This should be closer to my understanding of your issue.

 

        static Point3d GetClosestPointToStartTangent(Curve curve, Point3d point)
        {
            var line = new Line3d(curve.StartPoint, curve.GetFirstDerivative(curve.StartPoint));
            return line.GetClosestPointTo(point).Point;
        }

        static Point3d GetClosestPointToEndtTangent(Curve curve, Point3d point)
        {
            var line = new Line3d(curve.EndPoint, curve.GetFirstDerivative(curve.EndPoint));
            return line.GetClosestPointTo(point).Point;
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report