Moving a sheet within a box...

woopigeon

New member
Joined
Oct 29, 2020
Messages
6
Hi,

I'm a programmer that isn't very good at maths (I know, bad career choice). I'm desperately trying to solve the following:

I have a box and within that box is a sheet of paper. I can move this sheet of paper horizontally and vertically based on it's centre point percentage. But I am trying to make it so the sheet of paper stays within the boundaries of the box without it clipping out side...

The image attached shows what I have at the top and what result I need at the bottom if I enter "0" for the horizontal and vertical percentage.
 

Attachments

  • box.jpg
    box.jpg
    84.6 KB · Views: 5
Hi,

I'm a programmer that isn't very good at maths (I know, bad career choice). I'm desperately trying to solve the following:

I have a box and within that box is a sheet of paper. I can move this sheet of paper horizontally and vertically based on it's centre point percentage. But I am trying to make it so the sheet of paper stays within the boundaries of the box without it clipping out side...

The image attached shows what I have at the top and what result I need at the bottom if I enter "0" for the horizontal and vertical percentage.
Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:

READ BEFORE POSTING

Please share your work/thoughts about this problem.
 
Hi,

I'm a programmer that isn't very good at maths (I know, bad career choice). I'm desperately trying to solve the following:

I have a box and within that box is a sheet of paper. I can move this sheet of paper horizontally and vertically based on it's centre point percentage. But I am trying to make it so the sheet of paper stays within the boundaries of the box without it clipping out side...

The image attached shows what I have at the top and what result I need at the bottom if I enter "0" for the horizontal and vertical percentage.
You might consider the rectangle within which the center of the paper has to stay, rather then the entire box. Then just place the center of the paper at the proper percentage of that rectangle.

How big will this smaller rectangle be, compared to the box?
 
woah ok.

Ok, so to simplify my matter I focus on issue at a time. So lets focus on the horizontal alone and then apply whatever works to the vertical.

So in my mind I had I need to get the percentage of the box...

I take the value the width 790 divide by 100, this gives me 7.9
So 7.9 is one percent.
I need to now work out the sheet of papers percentage to the boxes width.
790 - 100 = 690
...and now my brain fails me cause I get mixed up what to do next.
 
You might consider the rectangle within which the center of the paper has to stay, rather then the entire box. Then just place the center of the paper at the proper percentage of that rectangle.

How big will this smaller rectangle be, compared to the box?
The white paper is 100 x 100
 
The white paper is 100 x 100
That's not at all what I asked.

How far does the center of the paper move when you slide the paper from as far left as it can go (and still be inside the box), to as far right as it can go?

Then move it a given percentage of that distance.
 
That's not at all what I asked.

How far does the center of the paper move when you slide the paper from as far left as it can go (and still be inside the box), to as far right as it can go?

Then move it a given percentage of that distance.
....oh right sorry.

half in.
1604000168487.png
 
1604000755493.png

The bottom halve of the paper doesn't matter as that would be regarding the vertical part of the box. The 50 however needs to be bumped into the box...
 
Looks like I have to explain myself visually! Here is the inner rectangle I have in mind:

FMH125926.jpg

As long as the center of the white square is within the green rectangle, its edges will be within your gray box. I was asking for the dimensions of the green box. My suggestion is to make your percentages relative to the green rectangle, not the gray, and place the center accordingly.
 
Looks like I have to explain myself visually! Here is the inner rectangle I have in mind:

View attachment 22710

As long as the center of the white square is within the green rectangle, its edges will be within your gray box. I was asking for the dimensions of the green box. My suggestion is to make your percentages relative to the green rectangle, not the gray, and place the center accordingly.
ohhh I see what you mean. Thank you Doctor.
 
Top