Controlling a line from a non zero offset

Started by vojo, December 09, 2014, 03:40:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vojo

Trying to build a 30 degree line starting from some non zero offset

Starting from zero offset (lower left corner) is pretty straightforward...top picture attached

Starting from non zero offset (say in the middle of a square) seems tough (or at least I cant figure it out)....bottom picture attached

Tried setatref et al, bound, etc.....can get close but does not work in all cases

Thoughts guys

Yacine

#1
Hi Vojo,
The line with offset is of a form y=a*x+b
In your case you bound y to a form a*x (without b)
So you need to modify the formula to something like: GUARD(Controls.Row_1*TAN(30 deg)+40 mm)
You need to do this for both the begin and the end point of the line.
I enclose an adapted shape
Yacine

vojo

Thx....step in right direction, though its a subset of the general problem
Aka what if the line starts in the middle of square

wait...I could do the following
   1) find the point in the middle (your control_1)....when shape is completed...this comes from a more complex calculation
   2) take the X compoenent....do something like controls.row_2.y = - controls.row_1.x * tan (30 deg)     ....controls.row_2.x = 0
   3) then do controls.row_3.x is  BOUND to controls.row_1.x...controls.row_3.y = controls.row_3* tan 30 deg

I will try that

That pesky required reference to width*0 and height*0 for control points made it hard/unclear to do this in one step

thx

Yacine

#3
Hi Vojo,

QuoteThat pesky required reference to width*0 and height*0 for control points made it hard/unclear to do this in one step
If you change the X and Y behavious of the control points to OffsetMin (2), you get distances instead of ratios of width and height.
Yacine

wapperdude

#4
It can be much simpler.  First, the line equation in general terms is (y-y1)= m*(x-x1)  where m is the slope =(y2-y1)/(x2-x1).  Let the pair (x1,y1) be your lines starting point, and the pair (x2,y2) be the end point.  The slope m also equals tan(angle), or in your case, tan(30 deg).

For a completely free form case, let your top group shape have two control points.  Let controls.row_1 be the begin point of your line, e.g., BeginX, and Begin Y.  Let  controls.row_2 be your end points EndX and EndY of the line sub-shape.  Thus, controls.row_1 becomes any arbitrary offset.  Controls.row_2 sets the end point, and the line spans between the two control points.

Now use the equation above to set controls.row_2.y by formula:  y= m*(x-x1)+y1.  Specifically, controls.row_2.y = GUARD((Controls.Row_2-Controls.Row_1)*TAN(30 deg)+Controls.Row_1.Y)

You can substitute any coordinate pair for the start point by simply replacing the controls.row_1 and controls.row_1.y with values that you desire...just as long as everything is using same coordinate system.

Should do the trick.

HTH
Wapperdude
Visio 2019 Pro

vojo

thx guys

Still had behaviors at 0...will try 2

However, with behaviors at 0...its a bit more complicated than a simple y-y0=M(x-x0) equation.

1.  need to compute the distance of the original offset point aka depth = sqrt (...)
2.  Take the y component of that offset point and subtract the depth*sin (30 deg)     
3.  this new point  (0,offset.y-depth*sin(30 deg) is the start of the line at widht = 0
4   then can use bound and guard

gets me the closest to the correct solution so far (depending on the offset and distance involved with #4, it tends to drift some).
I tried the other examples....they seem to track worse

Here is what I am trying to do (select the manifold at the bottom)


wapperdude

Ah!  I see what you're trying to do.  Nice.

After studying what's going on, I focused only on the rectangular shape.  It would seem a slight change will solve your problem.  Controls.row_1 and row_2 are the foundation and controls.row_4 reference what they do.

The changes would be as follows:
  Keep controls.row_1 as starting point for your rectangle, but make
     1. the 2nd point of the rectangle controls.row_2.  Seems logical and simplifies calcs.
     2.  make the 3rd point (the upper right point), be controls_row4.  Just that.  Formula changes will be applied to the control point.
     3.  make the final, upper left point, based upon a formula using controls_row4 and the X-, Y- changes of the baseline.
            X-value = Controls.Row_4-User.Row_7
            Y-value = Controls.Row_4.Y-User.Row_8
            ...and then finish off the shape as usual.

     4.  The two user rows are the delta X and delta y changes of the Line:
             Row_7:  =Controls.Row_2-Controls.Row_1
             Row_8:  =Controls.Row_2.y-Controls.Row_1.y

     5.  Finally, controls.Row_4, you only need to define the Y-value by formula and uses controls.row_2 as its offset reference:
             =GUARD((Controls.Row_4-Controls.Row_2)*TAN(30 deg)+Controls.Row_2.Y)

This seems to work for any position of the control points.  Did not make any changes to controls.Row_3 or Row_5.

HTH
Wapperdude
Visio 2019 Pro

vojo

much appreciated....will give it a try...thx

vojo

ok...so the actual solution is this

Controls.row_3 = guard((controls.row_1+controls.row_2)/2)
Controls.row_3.y = guard((controls.row_1.y+controls.row_2.y)/2)

Controls.row_4 = <anything>
Controls.row_4.y = guard((controls.row_4-controls.row_3)*tan(30 deg) + controls.row_3.y)

Geometry
X1 = controls.row_1                                                            Y1 = controls.row_1.y
X2 = controls.row_1+controls.row_4-controls.row_3              Y2 = controls.row_1.y+(controls.row_4-controls.row_3)*tan(30 deg)
X3 = controls.row_2+controls.row_4-controls.row_3              Y3 = controls.row_2.y+(controls.row_4-controls.row_3)*tan(30 deg)
X4 = controls.row_2                                                            Y4 = controls.row_2.y
X5 = geometry1.X1                                                             Y4 = geometry1.Y1

Everything lines up now and controls 4 is midpoint of back edge in all cases