Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.
Task is to fit a rectangle with given width 'w' into another rectangle with given size 'a' x 'b', so that all four edges of inner rectangle touches the outer rectangle ( at [x,0],[0,y],[a-x,b],[a,b-y] ). Now I need a formula to calculate x and y from given a,b,w
I have made an animation, which illustrates the problem. (OpenSCAD script below) If 'x' is known, solution is simple to calculate 'y' and 'w'. (see fit_for_given_x(x) ) Now I need a function fit_for_given_w(w) to calculate 'x' and 'y' // Animation: FPS=5 STEPS=100 a=13; b=15; module fit_for_given_x(x) { y=b-(b/2+sqrt(x*x+b*b/4-a*x)); w=sqrt(x*x+y*y); inner_rect=[[x,0],[0,y],[a-x,b],[a,b-y]]; color("blue")linear_extrude(0.01)polygon(points=inner_rect); color("black")translate([x,0,0])linear_extrude(0.02)text(str("x=",x),size=1,halign="center",valign="top"); color("black")translate([0,y,0])linear_extrude(0.02)text(str("y=",y),size=1,halign="right",valign="center"); color("black")translate([x/2,y/2,0])linear_extrude(0.02)text(str("w=",w),size=1,halign="left",valign="bottom"); } if(is_num($t)) { if($t>0)if($t<1) { fit_for_given_x(a*$t); } } color("black")translate([a/2,b,0])linear_extrude(0.02)text(str("a=",a),size=1,halign="center",valign="bottom"); color("black")translate([a,b/2,0])linear_extrude(0.02)text(str("b=",b),size=1,halign="left",valign="center"); outer_rect=[[0,0],[0,b],[a,b],[a,0]]; color("yellow")linear_extrude(0.001)polygon(points=outer_rect); Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
I think you need to know the height of the internal rectangle as there are many ways to place one of width w that give different heights. On Thu, 25 Mar 2021 at 09:27, bassklampfe <[hidden email]> wrote: Task is to fit a rectangle with given width 'w' into another rectangle with given size 'a' x 'b', so that all four edges of inner rectangle touches the outer rectangle ( at [x,0],[0,y],[a-x,b],[a,b-y] ). Now I need a formula to calculate x and y from given a,b,w _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Nope. As long as 'a' < 'b' there is only one solution of 'x' and 'y' for a given 'w'. Animation makes this pretty clear. (Please keep in mind, we talk about rectangles)
Or can you show me a second solution for a=13,b=15,w=9.16399 (from screenshot)? I'd be very interested. If 'a' > 'b' there are some 'w' values, which have no possible no solution, (in case of 'x*x+b*b/4-a*x' gets negative) but I don't care about these, because I can assure, 'a' < 'b' for my special use case. Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Are you asserting that if the inner rectangle had half the height, all 4 corners would touch the outer edges in the same places? I am with nop head on this, the ratio of w to h matters. On Thu, 25 Mar 2021 at 10:18, bassklampfe <[hidden email]> wrote: Nope. As long as 'a' < 'b' there is only one solution of 'x' and 'y' for a given 'w'. Animation makes this pretty clear. (Please keep in mind, we talk about rectangles) _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Question: Have you LOOKED at the animation??? It explains more than 1000
words. The both restrictions * both outer and inner must be rectangular * inner must touch outer with one edge at each side enforce one only solution for x. If I have x, I can easily calculate y=b-(b/2+sqrt(x*(x-a)+b*b/4)); and I can also calculate the length of the other side of the inner rectangle (let's call it v) v=sqrt((a-x)*(a-x)+(b-y)*(b-y)); Am 25.03.21 um 11:43 schrieb Will Hardiman: > Are you asserting that if the inner rectangle had half the height, all > 4 corners would touch the outer edges in the same places? I am with > nop head on this, the ratio of w to h matters. > _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Yes if you specify x and y there is only one w and h that works but if you just have a line of length w you can place it at any x and get a corresponding y and then project at right angles to get the other two points giving different h values depending on the initial x. On Thu, 25 Mar 2021 at 11:01, <[hidden email]> wrote: Question: Have you LOOKED at the animation??? It explains more than 1000 _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Sorry, but no.
I did as you suggested. Lets have a=13, b=15, w=9 (to be similar to screenshot of animation) I place the line at an arbitrary location touching a and b, create two right angles. (did this with Inkscape). But – SURPRISE – they don't fit on the other side creating a rectangle. See There is only ONE x, where the two dotted lines will match, believe me... Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Ok, yes I see the problem now. I think by symmetry and similar triangles y / x = (a-x) / (b- y). And x^2 + y^2 = w^2, so you have to solve those two simultaneous equations. On Thu, 25 Mar 2021 at 14:27, bassklampfe <[hidden email]> wrote: Sorry, but no. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by bassklampfe
I tried to solve this algebraically, and ended up with a quartic in x that doesn't look like it has easy solutions at first glance:
4x^4 - 4a x^3 + (a^2 + b^2 - 4w^2 ) x^2 + 2 w a x + (w^4- b^2 w^2) = 0 Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by bassklampfe
When you've solved that, then consider a room, say 14ft by 12ft,
and you need to cut a scaffold plank, 1 foot wide, with square
ends, so that it fits exactly diagonally across the corners, as a
platform for artexing the ceiling, say. What length plank is
required? (The four corners of the plank touch the walls). Has to
be a formula, no iterative process/drawing allowed. On 25/03/2021 09:26, bassklampfe wrote:
Task is to fit a rectangle with given width 'w' into another rectangle with given size 'a' x 'b', so that all four edges of inner rectangle touches the outer rectangle ( at [x,0],[0,y],[a-x,b],[a,b-y] ). Now I need a formula to calculate x and y from given a,b,w _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
I gave the equation to Wolfram to solve. It did but answer is horrible: https://www.wolframalpha.com/input/?i=solve+sqrt%28w%5E2+-x%5E2%29%2Fx+%3D+%28a-x%29+%2F+%28b+-+sqrt%28w%5E2+-x%5E2%29%29 On Thu, 25 Mar 2021 at 17:08, Ray West <[hidden email]> wrote:
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
No offense, but this whole thing starts feeling like we are doing
somebody's homework here. Regards, Jan On 3/25/21 1:08 PM, nop head wrote: > I gave the equation to Wolfram to solve. It did but answer is horrible: > https://www.wolframalpha.com/input/?i=solve+sqrt%28w%5E2+-x%5E2%29%2Fx+%3D+%28a-x%29+%2F+%28b+-+sqrt%28w%5E2+-x%5E2%29%29 > <https://www.wolframalpha.com/input/?i=solve+sqrt%28w%5E2+-x%5E2%29%2Fx+%3D+%28a-x%29+%2F+%28b+-+sqrt%28w%5E2+-x%5E2%29%29> > > > On Thu, 25 Mar 2021 at 17:08, Ray West <[hidden email] > <mailto:[hidden email]>> wrote: > > When you've solved that, then consider a room, say 14ft by 12ft, and > you need to cut a scaffold plank, 1 foot wide, with square ends, so > that it fits exactly diagonally across the corners, as a platform > for artexing the ceiling, say. What length plank is required? (The > four corners of the plank touch the walls). Has to be a formula, no > iterative process/drawing allowed. > > On 25/03/2021 09:26, bassklampfe wrote: >> Task is to fit a rectangle with given width 'w' into another >> rectangle with given size 'a' x 'b', so that all four edges of >> inner rectangle touches the outer rectangle ( at >> [x,0],[0,y],[a-x,b],[a,b-y] ). Now I need a formula to calculate x >> and y from given a,b,w >> >> >> >> I have made an animation, which illustrates the problem. >> (OpenSCAD script below) >> >> If 'x' is known, solution is simple to calculate 'y' and 'w'. (see >> fit_for_given_x(x) ) >> Now I need a function fit_for_given_w(w) to calculate 'x' and 'y' >> >> >> // Animation: FPS=5 STEPS=100 >> >> a=13; >> b=15; >> >> module fit_for_given_x(x) >> { >> y=b-(b/2+sqrt(x*x+b*b/4-a*x)); >> w=sqrt(x*x+y*y); >> >> inner_rect=[[x,0],[0,y],[a-x,b],[a,b-y]]; >> color("blue")linear_extrude(0.01)polygon(points=inner_rect); >> color("black")translate([x,0,0])linear_extrude(0.02)text(str("x=",x),size=1,halign="center",valign="top"); >> color("black")translate([0,y,0])linear_extrude(0.02)text(str("y=",y),size=1,halign="right",valign="center"); >> color("black")translate([x/2,y/2,0])linear_extrude(0.02)text(str("w=",w),size=1,halign="left",valign="bottom"); >> } >> >> if(is_num($t)) >> { >> if($t>0)if($t<1) >> { >> fit_for_given_x(a*$t); >> } >> } >> >> color("black")translate([a/2,b,0])linear_extrude(0.02)text(str("a=",a),size=1,halign="center",valign="bottom"); >> color("black")translate([a,b/2,0])linear_extrude(0.02)text(str("b=",b),size=1,halign="left",valign="center"); >> >> outer_rect=[[0,0],[0,b],[a,b],[a,0]]; >> color("yellow")linear_extrude(0.001)polygon(points=outer_rect); >> >> ------------------------------------------------------------------------ >> Sent from the OpenSCAD mailing list archive >> <http://forum.openscad.org/> at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email [hidden email] <mailto:[hidden email]> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to [hidden email] > <mailto:[hidden email]> > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to [hidden email] > -- Jan Wieck Principle Database Engineer Amazon Web Services _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by nophead
I stopped and threw away my work when I saw that you had gotten to
the same "two equations and two unknowns" that I started with. I
didn't yet have a simple expression, but where I stopped I had
fairly straightforward case of the quadratic function. I was pretty
sure it was uglier than it needed to be, but didn't feel like
spending more time simplifying - and it seemed likely that somebody
else would do it easier and faster. It was maybe half a line of
text long at that point. I'm pretty confident that the math salad
that Wolfram came up with is unnecessary.
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by nophead
Your input seems better input as what I got for (w² − x²)^(0.5) = − ( − b + (b² + 4(x² − ax))^(0.5))/2 at https://www.dcode.fr/equation-solver I will try, if the solution from wolframalpha is correct thanks Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by MostlyHarmless
I can tell you, you are not. Solution of this problem is one missing part to build steel constructions like without mechanical errors and in the final step to build full customizable railway steel bridges in OpenSCAD. When all things are completed, I will happily share the result with you. Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by nophead
I'm not scared by the answer, as long as it is correct – which still has to be prooved. But isn't it this, why we use computers? To do calculations, which feels like horror to some people Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by bassklampfe
On 3/25/21 2:28 PM, bassklampfe wrote:
> MostlyHarmless wrote > No offense, but this whole thing starts feeling like we are doing > somebody's homework here. > > I can tell you, you are not. > > Solution of this problem is one missing part to build steel > constructions like > > without mechanical errors and in the final step to build full > customizable railway steel bridges in OpenSCAD. As said, no offense. I'm just around the interwebs since the late 80's (yeah, it was email and netnews over UUCP back then), so I have seen this sort of math problem without explaining a practical purpose once or twice before ;) My gut feeling is that it requires taking the angles into account. The inner rectangle has a certain rotation that produces 4 right triangles, which all have identical angles. I'll have to think about it a bit longer, but maybe that will give us the 3rd equation to eliminate one of the variables. Regards, Jan > > When all things are completed, I will happily share the result with you. > > > > ------------------------------------------------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to [hidden email] > -- Jan Wieck Principle Database Engineer Amazon Web Services _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by nophead
Nop head was on the right path. But he left the a,b,w as variables for Wolfram. It doesn't complete within the allotted time, so fails to simplify. I tried specifying the example input variables of A=13, B=15 and W=9.16, which allows the algorithm to simplify earlier. Now it solves for x=8.57 (and also some imaginary solutions). The original request was for a formula to set up Fn(a,b,w) returning x. I am not able to solve the problem the way Wolfram did. It appears to use 2 simultaneous equations (see the two lines on the graph). Nop head specified those. Interesting problem that seems like it out to be easy, but seem to actually be computationally complex. Kevin On Thu, Mar 25, 2021 at 1:10 PM nop head <[hidden email]> wrote:
_______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Maybe there's a clever way to solve this using trig, but I'm not seeing it---and the similarity relationship really seems like the fundamental defining property.
Solving a quartic isn't a big deal. But solving one *symbolically* like Wolfram Alpha does is completely pointless. The quartic formula is a horrible mess. Give up on the idea of having a formula, and definitely don't try to use the mess from Worlfram Alpha. You need to solve the equation numerically. BOSL2 has a polynomial root finder that will do the job. https://github.com/revarbat/BOSL2/wiki/math.scad#function-real_roots include<BOSL2/std.scad> a=13; b=15; w=9; function getx(a,b,w) = let( options = real_roots([4,-4*a, a*a+b*b-4*w*w, 2*w*w*a, pow(w,4)-b*b*w*w]), posopt = [for (x=options) if (x>0) x] ) assert(len(posopt)==1) posopt[0]; x=getx(a,b,w); y=b-(b/2+sqrt(x*x+b*b/4-a*x)); echo(x=x,y=y); echo(sqrt(sqr(x)+sqr(y))); inner = [[x,0], [0, y], [a-x,b], [a,b-y]]; linear_extrude(height=1)square([a,b]); color("red")linear_extrude(height=1.1)polygon(inner);
Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
In reply to this post by nophead
When you described it as "horrible", I expected something more along the lines of "a bit awkward", but horrible does not give that solution justice. This goes beyond horrible, and into pure terror... Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to [hidden email] |
Free forum by Nabble | Edit this page |