Page 1 of 1

Constrained Rectangle

Posted: Mon Mar 30, 2020 5:09 pm
by willzz32
Hi All

I'm hoping i may be able to get some help with an exe i'm trying to create. I'm trying to create a rectangle within a space that changes raito but is constrained within the space of a second rectangle. It's mainly to workout a projection canvas and then drop 16:9 projectors 'Rectangles' over the canvas.
I thought this would be easy but i can't seem to crack it, It's probably something very simple but i just can't see the solution.
Any help would be much appreciated.

Re: Constrained Rectangle

Posted: Mon Mar 30, 2020 5:37 pm
by martinvicanek
I was not sure from your schematic what your goal is so I'll try to answer your question.

Suppose you have a rectangle with sides a and b, and you want to fit it into another rectangle with sides A and B, while maintaining the aspect ratio a/b. Your scale factor is

scale = min(A/a,B/b)

so your new rectangle will have the dimensions

a' = scale*a
b' = scale*b

Does that answer your question?

Re: Constrained Rectangle

Posted: Mon Mar 30, 2020 5:43 pm
by willzz32
Thanks for pointing me in the right direction. It most definitley helps.
I'm just creating a projection calculator to help me setting up projection on shows. I know there's a few out there already but i just wanted to see if i could do my own.
I really appreciate the fast response thank you. Matt

Re: Constrained Rectangle

Posted: Mon Mar 30, 2020 7:50 pm
by martinvicanek
Here is an example.

Re: Constrained Rectangle

Posted: Mon Mar 30, 2020 8:43 pm
by willzz32
Hi Martin

Thank you very much for the example.

It really helps me understand. Sorry for being a bit slow.

Re: Constrained Rectangle

Posted: Mon Mar 30, 2020 11:40 pm
by pshannon
thanks Martin, however, where is the rest of the image? lol

Re: Constrained Rectangle

Posted: Tue Mar 31, 2020 2:43 pm
by martinvicanek
http://www.lenna.org/full/len_full.html
Warning: may contain nudity!

Re: Constrained Rectangle

Posted: Tue Mar 31, 2020 2:49 pm
by pshannon
martinvicanek wrote:http://www.lenna.org/full/len_full.html
Warning: may contain nudity!


Thanks, she is nice, but I was just playing around. Teasing us with the half image. :)

Re: Constrained Rectangle

Posted: Tue Mar 31, 2020 3:44 pm
by Spogg
You do know that as moderators we really ought to delete porn.
But this is art, right?
Nice proper real and valid art.
And not porn, right?

Cheers

Spogg

Re: Constrained Rectangle

Posted: Tue Mar 31, 2020 4:10 pm
by martinvicanek
No, not porn. Art.
I would never post porn.