Another relationship of variables

Click For Summary
SUMMARY

The discussion focuses on calculating the column (C) and row (R) of images arranged in a 2D grid, specifically for a software project. The correct formulas established are C = Int((I - 1) / 5) + 1 and R = I - (C - 1) * 5, where I represents the image index. The initial confusion regarding the calculation of R was clarified, leading to a straightforward solution for aligning images in a grid format.

PREREQUISITES
  • Understanding of integer division and modulus operations
  • Familiarity with programming concepts such as loops and indexing
  • Basic knowledge of 2D array structures
  • Experience with a programming language that supports integer functions (e.g., Python, Java)
NEXT STEPS
  • Research integer division and its applications in programming
  • Learn about 2D array manipulation in your preferred programming language
  • Explore the use of loops for iterating through data structures
  • Investigate graphical user interface (GUI) frameworks for image alignment
USEFUL FOR

Software developers, particularly those working on graphical applications or image processing, will benefit from this discussion as it provides insights into efficient image arrangement algorithms.

eNathan
Messages
351
Reaction score
2
Yet again, I am programming a software to align pictures on a 2D plane, kinda like they are in windows exploror. I need to find a relationship between these.

I C R
_______
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
6 1 1
7 2 2
8 2 3
9 2 4
10 2 5
11 3 1

I would be my for loop counter, C would be the colum of picture I, and R would be what row it belongs to.

I already know that
C = Ceil(i / 5);
And I have come close to finding the value of R, so far I have
R = i - (Floor(i/(5 + C))*5);
But I know the latter equation is wrong, I just can't seem to figure it out out.

Thanks in advanve :smile:
 
Physics news on Phys.org
eNathan said:
...6 1 1
7 2 2
8 2 3
Are you sure 6 1 1? I think it should read 6 2 1.
C = [(I - 1) / 5] + 1. Where [...] is a function that takes the integer part before the decimal point of a real number. Ex : [1.5] = 1.
In some programming languages, you can write it as : C = Int((I - 1) / 5) + 1.
R = I - (C - 1) * 5.
Viet Dao,
 
Last edited:
VietDao29 said:
Are you sure 6 1 1? I think it should read 6 2 1.
C = [(I - 1) / 5] + 1. Where [...] is a function that takes the integer part before the decimal point of a real number. Ex : [1.5] = 1.
In some programming languages, you can write it as : C = Int((I - 1) / 5) + 1.
R = I - (C - 1) * 5.
Viet Dao,

Oh my It was soooo simple! I am speechless. Of course, just subtract from I, 5 C abount of times (and add one of course).

Thank you very much.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K