Jump to content

(difficult problem)If A and B don't rotate, look for B to put in A, the leftmost position.


ssdd

Recommended Posts

Maybe A/sinA=B/SinB=C/SinC triangle rule. Know A is length and angle is internal opposite angle from the 2 lines pline etc Then Know angleB AngleC can work out B & C 

 

Need some smart angle calcs.

 

image.png.21eed9211c7044e7c0e33ff69c40dabf.png

 

The middle bottom request in dwg can be done using move  .X .Y no code required

 

Edited by BIGAL
Link to comment
Share on other sites

Ok universal solution pick 2 alignment points this is equivalent to a length and an angle, pick other sides sin rule still applies. This should help ver and hor as it uses the side angle.

 

image.png.d32fd07433df3c1cea42661ef8b57036.png

 

Any one out there please feel free to code. Needs pline sector picked, clockwise angles, not a straight forward solution.

 

Thinking more just pick intersection point on pline.

Edited by BIGAL
Link to comment
Share on other sites

Some are mathematically impossible unless you rotate object B, even then some of the 4 point just have no solution as 1 point will just not touch.

 

The 3 point are somehow solvable as it is a circle solution.

 

In some software that I have used, it did offset from side boundaries, slide along line, very, very complex.

 

Anyway your dwg has lots of problems for a code solution, 1st the circles do not have a Z so they need that, can be done.

 

Using a simple linear method pick 1st circle with z, pick 2nd circle with z, pick next circle change z and write text value, pick next circle change z and write text value.

One problem is you have circles with text Z as top bottom so a automation routine needs to be ran twice. Ie find text find circle next to it.

 

If your happy doing lots of picks then text, circle, text,  circle, circle, draw text, circle, draw text, next.

Edited by BIGAL
Link to comment
Share on other sites

The track to which you want B to slide inside A.

 

I have to think about it for a few days, but I don't find a suitable algorithm. Hope to have friends to help!

Edited by ssdd
Link to comment
Share on other sites

This is not an easy solution. You have to use THIS function, and check against all the points of the inner polyline. If any are outside the boundary, reject the solution and keep using the last successful one. I imagine this would be pretty slow.

1) There are cases where this would not work, so you would also have to include an intersection check between every segment of the inner polyline to every segment of the outer polyline to prevent bridging of concave segments.

2) Also the inner or outer polylines would not be able to be able to have any non-linear segments.

 

I wouldn't write this for free. Not sure I could even do it.

Link to comment
Share on other sites

The free part is what I said already a non rotated version 2 points, pick a point, move so touches a side, slide along this bearing for second point till distance is zero. This was house setout algorithm on an allotment.

 

Thinking the 3 point set master side, pick 2nd point and 2nd side using intersectwith check offset of 2nd point and slide and rotate also check 3rd point + segment at same time till a tolerance is met.There is possibly a 3 point circle solution.

Edited by BIGAL
Link to comment
Share on other sites

One approach to find the left-most position of shape B that is totally within shape A is to use a brute force numerical solution.  This involves repeatedly positioning shape B with respect to shape A in a systematic process until the left most valid position is found.  For each position of shape B a Boolean union function is performed with shapes A and B. If the area of the resulting shape is not greater than the area of shape A then the left-most vertex of shape B is recorded along with the position of shape B. Boolean union results are evaluated for each successive repositioning of shape B.  If the left-most vertex of B is less than the previously recorded left-most position and the unioned area of A and B  is not greater than shape A, then the new left-most position of B is redefined.

 

A nested do loop is used to move B around A. The inner loop moves shape B around the circumference of A for a specific vertex of B.  The outer loop increment the vertex of B that is used. The first iteration moves shape B such that vertex 1 of B (B1) travels around the circumference of A.  Then shape B is moved around A with vertex B2 on the outline of A.  This is repeated until all the vertices of B have been used.  The amount that B is moved for each step of its “walk” around A needs to be defined. Lets call this distance DS. DS could be user defined or set as a function of the smallest dimension of the minimum box that surrounds A E.g., 1/100 the distance of (x max – x min) or (y max – y min) whichever is smaller.

 

The “walk” around A will first position a vertex of B at points along the line from A1 to A2, then A2 to A3, etc.   A parametric definition of a line should be used.  That is:

 

   P = P1 + t (P2P1)  (vector form)

   or

  Px = Px1 + t (Px2 – Px1)  (scalar form)

  Py = Py1 + t (Py2 – Py1) 

 

Here, a value of t = 0 places P at P1. When t = 1, P = P2.  A value of t = 0. 1 defines a point on the line from P1 to  P2 one tenth the distance along P1P2 from P1.  The parametric variable t is incremented by a value of delta_t (DT) from 0 to 1 for each line of shape A.   The value of DT is a function of DS and the length of the line segment.   The following could be used:

DT = DS/(distance from P1 to P2)

 

For example, let’s assume the distance from one vertex to the next is 12.7” and we want to evaluate the position of B for steps no larger than 0.5” (DS).

DT = 0.5/ 12.7 =  0.03937

 

Note that (1 / 0.03937) =25.4.  This means that B will be evaluated at 25 different spots along the 12.7” long line.

 

If the distance from one vertex to the next is 50.6” then DT = 0.00988 and B will be evaluated 101 times.

 

If the distance between consecutive vertices is greater than DS then t should be set to 0 and 1 (the location of the two vertices).

 

The Boolean union operation is computationally expensive but simplifies the math you need to program as it is an AutoCAD function. Several steps can be taken to minimize the need to do the Boolean union to speed computation.  For example, the minimum box for A and B should be determined. The program should first check if a portion of the minimum B box lies outside the minimum A box. If it does then the Boolean operation may be avoided and the program should move on to the next evaluation point. Experience will help to determine a good value for DS.   A fairly large value may be able to be used and then further refined for the section of the outline where a probable solution may lie.  A finer step size could be used with a converging algorithm to get a more accurate result.

 

If this approach sounds like one you would like to consider I can provide more detail about its implementation if you want it.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...