Cancel
Showing results for
Did you mean:

# How to auto divide the curve based on the position of near-by object

Valued Contributor

Assume I have a red curve L and assume it is just a line to make it simple and an black object (which will be selected by user). The black object may or may not overlap the red line L.  How could the red line L be devided into 2 segment L1 and L2 based on the position of the black object (the closest edege)?  The cut point is not needed to be perfect as long as it is somewhere in the midle of the projected black object.

I guess just let the user selected the edge of the black object will be sufficident.

3 REPLIES

# Re: How to auto divide the curve based on the position of near-by object

Siemens Phenom

Basically, you need to get a point P on the line L that is "near" the black object, B. Then you can use this point to divide the line. A few different ideas:

(1) Find the point P that is closest to B. Using SNAP, just call Snap.Compute.ClosestPoints.

(2) Find the centroid of B, and then project this onto the line L.

(3) Get the bounding box of B, find its center, and then project this center point onto the line L

(4) Find the extents of B in the direction of L, and use the mid-point of this extents interval

#3 would probably run the fastest.

None of these require the user to select an edge of B.

# Re: How to auto divide the curve based on the position of near-by object

Valued Contributor

I will try #3, assuming that I already found the bounding box of B and its center, what function should I use to project this point to L?

Thanks for the help

# Re: How to auto divide the curve based on the position of near-by object

Siemens Phenom
Snap.Compute.ClosestPoints would probably be easiest.