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

Compare 2 polyline

11 REPLIES 11
Reply
Message 1 of 12
hoathuongphuoc
1491 Views, 11 Replies

Compare 2 polyline

Hi All,

I have 1 problem, hope EveryBody can help me. This is, how can i compare 2 polyline together. Thanks.

11 REPLIES 11
Message 2 of 12
hgasty1001
in reply to: hoathuongphuoc

Hi,

What do  you need to compare?: length, color, number of segments, smooth, ccw/cw, bulges, etc...

 

Gaston Nunez

Message 3 of 12
cdinten
in reply to: hoathuongphuoc

which aspect whould like to compare? i.e, the polylines are equal or something else?

Message 4 of 12
hoathuongphuoc
in reply to: cdinten

I want to compare about their shape. how can i know them the same. I have attached image.

 

Message 5 of 12
cdinten
in reply to: hoathuongphuoc

so, you have to compare the 2 polylines with these aspects:
1.have the same count of points(vertexs, by using the Property NumberOfVertices), if not ,return false, else see 2.
2.for each vertex ,check the Bulge is equal(by using the Method GetBulgeAt),if not, return false, else see 3.
3. check the length of each segment(both arc and line) of the polylines are all equal(you may have to write some methods to calc the length of line or arc), if so we assume they are the same,if not,then not th same
at last, you may have to reverse one of the polyline, and do it over again, cause one may draw a polyline from Beginning to End, others may draw a polyline form End to Beginning

hope this be helpful to you.

Message 6 of 12
hgasty1001
in reply to: hoathuongphuoc

Hi,

 

If It's only the shape, and the polylines can be in any position, rotation and scale, it may be a difficult problem (a pattern recognition one). Can you explain if this is the case?, if not, the cdinten approach should be fine.

 

Gaston Nunez

 

 

Message 7 of 12
hoathuongphuoc
in reply to: hgasty1001

Yes. this is problem. Them only difference about position, rotation. Thanks for your help.

Message 8 of 12
hoathuongphuoc
in reply to: cdinten

Hi cdinten,

If 2 polyline have difference startpoint. What can you do?.  

Message 9 of 12
cdinten
in reply to: hoathuongphuoc

how about using Curve.ReverseCurve()? I have not test this method, may it work well.
Message 10 of 12
hoathuongphuoc
in reply to: cdinten

Thanks. I will try.

Message 11 of 12
hgasty1001
in reply to: hoathuongphuoc

Hi,

 

You may try using some invariant (on position and rotation) properties like surface, perimeter and maybe the inertia moment (measured from the centroid).

 

Gaston Nunez

Message 12 of 12
jeff
in reply to: hoathuongphuoc

What about checking distance between verticies and the difference of angle between vertices?

 

Also would need to check both ways and bulges but would'nt the distance from

vertex[0] to vertex[1]

vertex[0] to vertex[2]

............

and angle between a line from

vertex[0] to vertex[1]

&

vertex[0] to vertex[2]

 

have to be the same?

You can also find your answers @ TheSwamp

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost