turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

.NET

- Autodesk Community
- >
- AutoCAD Customization
- >
- .NET
- >
- Re: How to determine a point on one line

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

195 Views, 4 Replies

03-29-2014 09:47 AM

For example:

pt(0,0,0) is on the line((1,-1,0),(-1,1,0)

then I will get true

pt(1,2,3) is not on the line((1,-1,0),(-1,1,0)

then I will get false

Is there exist some method that I can use?

An example will be better. Very Thanks

Solved! Go to Solution.

Solved! by cdinten. See the answer in context.

one way is using Curve3d.IsOn() method, it has 6 overload version, you can choose one, this is the general approach

when it comes to Line, another way is using Point3d.GetDistanceTo()

a Line has StartPoint and EndPoint,abbr sp & ep.

if you want to check Point3d p, then:

d1=p.GetDistanceTo(sp);

d2=p.GetDistanceTo(ep);

length=theLine.Length;

if

A:d1+d2==length

or

B:|d1-d2|=length

thus we assume p is on the line,case A means p is on the line, case B means p on the extend, see image below:

Solved! by HelloWorlddd. See the answer in context.

Thank you very much, it's a easy way.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-29-2014 11:10 AM in reply to:
HelloWorlddd

Hi,

You can try this overloaded Isinside method;.

private bool IsInside(Line line, Point3d point) { return IsInside(line.StartPoint, line.EndPoint, point); } private bool IsInside(LineSegment3d line, Point3d point) { return IsInside(line.StartPoint, line.EndPoint, point); } private bool IsInside(Point3d start, Point3d end, Point3d point) { Vector3d v1 = start.GetVectorTo(point); if (v1.IsEqualTo(new Vector3d())) return true; Vector3d v2 = start.GetVectorTo(end); return v1.IsCodirectionalTo(v2) && 0.0 <= v1.Length && v1.Length <= v2.Length; }

Gilles Chanteau

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-30-2014 08:09 PM in reply to:
HelloWorlddd

one way is using Curve3d.IsOn() method, it has 6 overload version, you can choose one, this is the general approach

when it comes to Line, another way is using Point3d.GetDistanceTo()

a Line has StartPoint and EndPoint,abbr sp & ep.

if you want to check Point3d p, then:

d1=p.GetDistanceTo(sp);

d2=p.GetDistanceTo(ep);

length=theLine.Length;

if

A:d1+d2==length

or

B:|d1-d2|=length

thus we assume p is on the line,case A means p is on the line, case B means p on the extend, see image below:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-31-2014 04:21 AM in reply to:
cdinten

Thank you very much, it's a easy way.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-31-2014 04:24 AM in reply to:
HelloWorlddd

it should be. it is both easy to understand in mathematics and to convert this idea to code.

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.