If move the origin of a rectangle, rectangle gets smaller by a factor of amount moved

Geff

New member
Joined
Sep 18, 2017
Messages
1
Hello.

I'm trying to make a system whereby if I move from the origin of the rectangle (8 -directional movement) the rectangle will become smaller by the same proportion as amount moved.



There is currently the following relationship between length and height:

height = 0.6 * length

OR

length = 1.6666.. * height


I was able to figure out single direction movement (up-down), but diagonal movement seems to be tricky and that's what I need help with. The diagonal angles of movement are 30-degree (up-right), 150-degree (up-left), 210-degree (down-left) and 330 (down-right)

I have access to all of the x and y offsets whenever the origin is moved

Is there any way to figure out what length and height need to be subtracted if I know the offsets?

I know that I can get the area of the rectangle created by the diagonal movement x-offset and y-offset and subtract that area from the bigger rectangle. But, it would be easier to implement it if I can figure out the relationship between the diagonal movement x-offset and y-offset and figure out how much needs to be subtracted from the larger rectangle of concern.

in my testing subtracting the x-offset and y-offset directly from the rectangle's length and height seems to slightly skew the rectangle such that when you are reaching the corner the rectangle becomes squarish.

I say I need a relationship, because the program I'm using draws the rectangle based on the rectangles top-left coordinates and bottom right coordinates.

draw_rectangle(x1, y1, x2, y2, outline)

where
x1 = top left x
y1 = top left y
x2 = bottom right x
y2 = bottom right y
outline= not important for this discussion

Here is what I have right now:

area = 24000;

var rad_minor_multiplier = .6;

var rad_major = sqrt(area/rad_minor_multiplier);

var rad_minor = rad_major * rad_minor_multiplier;

var rad_major_multiplier = rad_major/rad_minor;

var starting_top_left_x = x + rad_major;

var starting_top_left_y = y - rad_minor;

var starting_bot_right_x = x - rad_major;

var starting_bot_right_y = y + rad_minor;


draw_rectangle(starting_top_left_x - x_units_moved - y_units_moved* rad_major_multiplier - x_units_moved_diag, starting_top_left_y + x_units_moved *rad_minor_multiplier + y_units_moved + y_units_moved_diag, starting_bot_right_x + x_units_moved + y_units_moved* rad_major_multiplier + x_units_moved_diag, starting_bot_right_y - x_units_moved * rad_minor_multiplier - y_units_moved - y_units_moved_diag , false);
 
I'm trying to make a system whereby if I move from the origin of the rectangle (8 -directional movement) the rectangle will become smaller by the same proportion as amount moved.

There is currently the following relationship between length and height:

height = 0.6 * length

OR

length = 1.6666.. * height

I was able to figure out single direction movement (up-down), but diagonal movement seems to be tricky and that's what I need help with. The diagonal angles of movement are 30-degree (up-right), 150-degree (up-left), 210-degree (down-left) and 330 (down-right)
What is the "origin" of a rectangle? I'm not familiar with that term, for shapes.

You say the rectangle will "become smaller" and you want the reduction to be proportional to a distance. Is the proportion:

Area to distance

Perimeter to distance

Length to distance

Height to distance

Something else to distance?

Also, I note that diagonals of rectangles with length-to-height ratio 5-to-3 form angles with the horizontal that are much closer to 31° than 30°.

It would help me to confirm what you're doing, if you were to post all of the actual values from a single, specific example.

Names like rad_major and rad_minor_multiplier probably make sense to you, but I don't know what they mean.
 
Top