Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have three points on the same Cartesian plane, i am also able to find the fourth points, which ultimately forms a rectangle kind of a shape, i am struggling to find the logic to find the rest of the points inside the rectangle based on the size of rows and columns mentioned. i try to explain the points pattern below.

i am not using any matrix. to visualize better, o - defines the points i want to achieve, 0 - defines the points i have already. The division of supposedly , rows and columns of the points i would like to take as variable values from the user.

1.this is what i have, 3 points

0 0

0

i am also able to find the fourth point, i.e.
0 0

0 o

3.I want to obtain a logic or equation which we give me any kind of shape when rows and columns are provided, to find the remaining points , basically complete the rectangle dynamically based on the size provided. eg-

for 3x3 points pattern

0 o 0

o o o

0 o o

for 4x3 points pattern

0 o o 0

o o o o

0 o o o

for 3x2 points pattern

0 o 0

0 o o

for 2x3 points pattern

0 0

o o

0 o

What I have tried:

i am not using any matrix. to visualize better, o - defines the points i want to achieve, 0 - defines the points i have already. The division of supposedly , rows and columns of the points i would like to take as variable values from the user.

1.this is what i have, 3 points

0 0

0

i am also able to find the fourth point, i.e.
0 0

0 o
Posted
Updated 7-Jun-20 23:04pm
v2
Comments
Rick York 8-Jun-20 13:46pm    
For help with the algorithm you might want to check out the Wykobi library at www.wykobi.com. There was an article here on it but I can't find it any more. It has a lot of computational algorithms specifically for this kind of thing and there is a demo program that illustrates most of them.

1 solution

Your question is a bit unspecific, because the progamming language is unclear. Some language have classes or libs for such computations.

Here is some nice trigonometry tutorial.

You must imagine your rectangles as two triangles and so find some formular. Best is to use paper and visualize the math.
 
Share this answer
 
Comments
Member 14856189 8-Jun-20 5:02am    
Hi, i will surely try it out. For your information, i am trying this in javascript language.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900