B
bassklampfe
Thu, Mar 25, 2021 9:26 AM
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
http://forum.openscad.org/file/t2988/rect-in-rect.png
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'
--
Sent from: http://forum.openscad.org/
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
<http://forum.openscad.org/file/t2988/rect-in-rect.png>
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'
--
Sent from: http://forum.openscad.org/
NH
nop head
Thu, Mar 25, 2021 9:50 AM
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 jjvb-openscad@bassklampfe.de
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(xx+bb/4-ax));
w=sqrt(xx+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 to discuss-leave@lists.openscad.org
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 <jjvb-openscad@bassklampfe.de>
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 to discuss-leave@lists.openscad.org
>
B
bassklampfe
Thu, Mar 25, 2021 10:18 AM
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 'xx+bb/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: http://forum.openscad.org/
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: http://forum.openscad.org/
WH
Will Hardiman
Thu, Mar 25, 2021 10:43 AM
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 jjvb-openscad@bassklampfe.de
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)
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 'xx+bb/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 http://forum.openscad.org/
at Nabble.com.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
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 <jjvb-openscad@bassklampfe.de>
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*)
>
> 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 <http://forum.openscad.org/>
> at Nabble.com.
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
JO
jjvb-openscad@bassklampfe.de
Thu, Mar 25, 2021 11:00 AM
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.
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.
>
NH
nop head
Thu, Mar 25, 2021 1:10 PM
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, jjvb-openscad@bassklampfe.de wrote:
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.
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, <jjvb-openscad@bassklampfe.de> wrote:
> 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 discuss-leave@lists.openscad.org
>
B
bassklampfe
Thu, Mar 25, 2021 2:27 PM
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
http://forum.openscad.org/file/t2988/Other-W.png
There is only ONE x, where the two dotted lines will match, believe me...
--
Sent from: http://forum.openscad.org/
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
<http://forum.openscad.org/file/t2988/Other-W.png>
There is only ONE x, where the two dotted lines will match, believe me...
--
Sent from: http://forum.openscad.org/
NH
nop head
Thu, Mar 25, 2021 2:47 PM
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 jjvb-openscad@bassklampfe.de
wrote:
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 http://forum.openscad.org/
at Nabble.com.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
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 <jjvb-openscad@bassklampfe.de>
wrote:
> 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 <http://forum.openscad.org/>
> at Nabble.com.
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
N
NateTG
Thu, Mar 25, 2021 4:48 PM
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: http://forum.openscad.org/
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: http://forum.openscad.org/
RW
Ray West
Thu, Mar 25, 2021 5:08 PM
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(xx+bb/4-ax));
w=sqrt(xx+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 to discuss-leave@lists.openscad.org
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 to discuss-leave@lists.openscad.org