Page 1 of 1

### Grid, Plane and Fix Anchor Geometry Problem

Posted: Sun Feb 16, 2020 3:15 pm
Problem statement:

you are given 4 coordinates of the points.

Grid size: X*Y (Both scalar parameters)

Plane Size: Px * Py (Both scalar parameters)

Fixed point: don't change the coordinate of the point.

GNx, No of plane on X axis= ceil(X/Px)
GNy, No of plane on Y axis= ceil(Y/Py)

this will generate the new grid of GNx*GNy.

Find the 4 coordinates of the new grid such that the position of the fixed point remains the same.

Hint: Slope of all the sides will remain same after transformation.
=================================================================================

Inputs :

Grid size: Int X, Int Y

Plane size: Int Px, Int Py

Points array :
[0] (x0,y0)
[1] (x1,y1)
[2] (x2,y2)
[3] (x3,y3)

Fixed Point index: Int FixedPoint

=================================================================================

Output Points array :
[0] (Nx0,Ny0)
[1] (Nx1,Ny1)
[2] (Nx2,Ny2)
[3] (Nx3,Ny3)

project euler answer will be: "Nx0,Ny0,Nx1,Ny1,Nx2,Ny2,Nx3,Ny4"
without rounding off up to 2 decimal points.

=================================================================================
Sample Example 1:

Grid Size: X*Y= 10*10

plane size: Px * Py = 2*2

corner to fix: 0

input points:
[0]-20,20
[1]-20,-20
[2]20,20
[3]20,-20

GNx, No of plane on X axis= ceil(X/Px) = ceil (10/2) = 5
GNy, No of plane on Y axis= ceil(Y/Py) = ceil (10/2) = 5

so GNx*GNy = 5*5

output points:
[0]-20,20
[1]-20,-20
[2]20,20
[3]20,-20

In this example planes of 2x2 is perfectly accommodated in grid size of 10x10, so the points will remain the same.

=================================================================================

calculate the values for the following:

Grid Size: X*Y= 9*9

plane size: Px * Py = 6*6

corner to fix:0

input points
[0]-18,20
[1]-18,-20
[2]15,15
[3]15,-15

GNx, No of plane on X axis= ceil(X/Px) = ceil (9/6) = 2
GNy, No of plane on Y axis= ceil(Y/Py) = ceil (9/6) = 2
so GNx*GNy = 2*2

What are the output points for the above?