Coordinate System: Place N Elements in a Square Format

  • Context: Undergrad 
  • Thread starter Thread starter bobby_kl
  • Start date Start date
  • Tags Tags
    System
Click For Summary
SUMMARY

This discussion focuses on the mathematical derivation of coordinates for placing 'n' elements in a square format within a coordinate system, specifically when 'n' is either odd or even. For odd 'n', the coordinates are calculated as (ir, jr) where 'i' and 'j' range from -k to k, with 'k' defined as (m-1)/2. For even 'n', the coordinates are derived using the formula ((i+1/2)r, (j+1/2)r) for 'i' and 'j' ranging from 1 to k. The distance 'r' represents the spacing between consecutive points both horizontally and vertically.

PREREQUISITES
  • Understanding of coordinate systems and plotting points
  • Basic knowledge of square root calculations
  • Familiarity with integer ranges and loops in programming
  • Concept of distance measurement in a Cartesian plane
NEXT STEPS
  • Implement the coordinate plotting algorithm in Python or JavaScript
  • Explore variations of coordinate systems, such as polar coordinates
  • Study algorithms for optimizing point placement in graphical applications
  • Learn about graphical libraries that facilitate plotting in 2D, such as Matplotlib or p5.js
USEFUL FOR

Mathematicians, computer scientists, and software developers interested in graphical representations and coordinate geometry will benefit from this discussion.

bobby_kl
Messages
1
Reaction score
0
Hello,

In a co-ordinate system i have to place some n elements in a square format as shown in fig. with a distance r. Instead of manually doing i would like to derive by equations, for x and y positions. The no. of elements may be 4 or 9 or 16 or 25 etc.. Can anyone help me..

thanks in advance
 

Attachments

  • 4.jpg
    4.jpg
    1.3 KB · Views: 459
  • 9.jpg
    9.jpg
    1.4 KB · Views: 505
Mathematics news on Phys.org
"In a co-ordinate system i have to place some n elements in a square format as shown in fig. with a distance r. "

Distance between two consecutive points horizontally and vertically r or distance to nearest neighbor r? (I'm going to assume "horizontally and vertically". If you meant straight line distance r, take my r to be your r divided by sqrt(2).)

You probably realized, since you have two pictures, that the problems breaks down into two cases: number of elements odd or even.
In either case, let m= sqrt(n) (by the conditions of the problem, m is also an integer.)

If n, number of elements is odd, m is also odd: let k= (m-1)/2 (so that m= 2k+1)Then there exist a point at the origin (0,0). Every point has coordinates (ir, jr) where i and j run from -k to k by integers (including 0, of course). An algorithm to plot them might be

For (integer)i= -k to k, step 1
{
For (integer j= -k to k, step 1
{
plot(i*r,j*r);
}
}
For example, if n= 9, then m= 3 and k= 1. The 9 points would have coordinates
(-r,-r), (0,-r),(r,-r), (0,-r), (0,0), (0,r), (r,-r), (r,0), and (r,r).

if n is even, then m is also even and m= 2k for some integer k. Now all points are of the form ((i+1/2)r, (j+1/2)r) for i= 1 to k and i= -1 to -k (skipping over 0). An algorithm to plot them (but not in the same order as above) might be:
For (integer)i= 1 to k, step 1
{
For (integer)j= 1 to k, step 1
{
plot((i+1/2)r,(j+1/2)r)
plot((-i-1/2)r,(-j-1/2)r)
}
}
 

Similar threads

  • · Replies 68 ·
3
Replies
68
Views
13K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 14 ·
Replies
14
Views
3K
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K