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?
Solved! Go to Solution.
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?
Solved! Go to Solution.
Solved by _gile. Go to Solution.
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; }
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; }
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; }
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; }
Can't find what you're looking for? Ask the community or share your knowledge.