Construct a regular grid in a rectangular box in 3 dimensional space

In summary, the conversation discusses the process of constructing a regular grid in a rectangular box in 3-dimensional space. The speaker has a specific set of parameters, including ranges for x, y, and z values and a limited number of points. They want to find a formula for the height, width, and length of each box in the grid to be equal. The conversation also touches on the use of a cubic equation to determine the pixel size for the grid. However, the expert suggests simplifying the process by arbitrarily defining a lattice mesh size of "1" and using array indices to represent the coordinates of each lattice point.
  • #1
DivergentSpectrum
149
15
Im trying to construct a regular grid in a rectangular box in 3 dimensional space
heres what i have to work with:
x has a range between xmin and xmax
y has a range beween ymin and ymax
z has a range between zmin and zmax
the total number of points is limited to a specific number n

i want the height,width,and length=pixelsize of each box in the grid to be equal.

i want to find the formula for pixelsize and a,b,c so that
xmin+pixelsize*(a-1)=xmax
ymin+pixelsize*(b-1)=ymax
zmin+pixelsize*(c-1)=zmax
where a,b,c is the number of x,y,z coordinates respectively
i don't know why this is turning out to be so difficult please help thanks
 
Last edited:
Mathematics news on Phys.org
  • #2
bluntwcrackrap said:
Im trying to construct a regular grid in a rectangular box in 3 dimensional space
heres what i have to work with:
x has a range between xmin and xmax
y has a range beween ymin and ymax
z has a range between zmin and zmax
the total number of points is limited to a specific number n

i want the height,width,and length=pixelsize of each box in the grid to be equal.

i want to find the formula for pixelsize and a,b,c so that
xmin+pixelsize*(a-1)=xmax
ymin+pixelsize*(b-1)=ymax
zmin+pixelsize*(c-1)=zmax
where a,b,c is the number of x,y,z coordinates respectively
i don't know why this is turning out to be so difficult please help thanks
What do you get when you try to do this with numbers, say a box that is 4" x 6" x 3", with xmin = ymin = zmin = 0, and pixelsize = 1/2"? If necessary, draw a sketch on a piece of paper.
 
  • #3
ok, i think i got it partially figured out:
pixelsize is given by the cubic equation
a*pixelsize^3+b*pixelsize^2+c*pixelsize+d=0
where
a=xmax*ymax*zmax+ymax*zmax+xmax*zmax+zmax+xmax*ymax+ymax+xmax-n+1;
b = -xmax * ymax * zmin - ymax * zmin - xmax * zmin - zmin - xmax * ymin * zmax - ymin * zmax - xmin * ymax * zmax - xmin * zmax - xmax * ymin - ymin - xmin * ymax - xmin;
c=xmax*ymin*zmin+ymin*zmin+xmin*ymax*zmin+xmin*zmin+xmin*ymin*zmax+xmin*ymin;
d = -xmin * ymin * zmin;

so before i start programming the cubic fomula (ughh), i have a concern as to where this may be right.
as i understand cubics have 3 answers, so which one do i chose? I am guessing if I am right so far then an equation of this form will only have 1 real root. I am kinda hesitant to start i really don't want to do any unneeded work.
 
  • #4
bluntwcrackrap said:
ok, i think i got it partially figured out:
pixelsize is given by the cubic equation
a*pixelsize^3+b*pixelsize^2+c*pixelsize+d=0
where
a=xmax*ymax*zmax+ymax*zmax+xmax*zmax+zmax+xmax*ymax+ymax+xmax-n+1;
b = -xmax * ymax * zmin - ymax * zmin - xmax * zmin - zmin - xmax * ymin * zmax - ymin * zmax - xmin * ymax * zmax - xmin * zmax - xmax * ymin - ymin - xmin * ymax - xmin;
c=xmax*ymin*zmin+ymin*zmin+xmin*ymax*zmin+xmin*zmin+xmin*ymin*zmax+xmin*ymin;
d = -xmin * ymin * zmin;
This is pretty ugly, and pretty much unreadable.

Before continuing on, please clarify for me what you're trying to do. You said you're trying to
construct a regular grid in a rectangular box in 3 dimensional space

I think of a grid as a two-dimensional framework. Are you thinking of a three-dimensional lattice of boxes inside the larger box?
i want the height,width,and length=pixelsize of each box in the grid to be equal.
What does this mean?
Pixels are normally two-dimensional regions on a (usually) flat surface. Also, pixels emit light. What do you mean by this term (pixel)?

bluntwcrackrap said:
so before i start programming the cubic fomula (ughh), i have a concern as to where this may be right.
as i understand cubics have 3 answers, so which one do i chose? I am guessing if I am right so far then an equation of this form will only have 1 real root. I am kinda hesitant to start i really don't want to do any unneeded work.
 
  • #5
yes, a 3 dimensional lattice.
im trying to write a program that evaluates a function of 3 varriables at the places where the lattice bars intersect.
 
  • #6
bluntwcrackrap said:
yes, a 3 dimensional lattice.
im trying to write a program that evaluates a function of 3 varriables at the places where the lattice bars intersect.
Why do you need n? If all you're trying to do is to evaluate some function at the lattice points, why not specify what the size of the lattice mesh is?

IMO, this unnecessarily complicates things, as does specifying minimum values for x, y, and z. For starters you can assume that the minimum values are all zero.

For example, let's say you had a box whose dimensions are 3' x 4' x 3' (x, y, and z, respectively), and that the lattice mesh is 6" or 1/2 '. I am assuming that we count all lattice points, including those at the 8 corners and along all 12 edges.

On one of the 3' x 4' faces, there are (3/(1/2) + 1)(4/(1/2) + 1) = (6 + 1)(8 + 1) = 7 * 9 = 63 lattice points. Since there are 3/(1/2) + 1 = 7 vertical rectangles that are parallel to the face I'm working with, then there are 7 * 63 = 441 lattice points in all.

The easiest thing to do is to arbitrarily define the lattice mesh size as "1" so that the box is now 7 x 9 x 7 "units" in size. To get to an individual lattice point, just count off the number of units in each direction and represent it as an ordered triple such as (3, 4, 2).
 
  • Like
Likes DivergentSpectrum
  • #7
Thanks, i think i was overcomplicating it, the minus 1's don't go there and its easier to deal with array indices this way:
pixelsize=((xmax-xmin)(ymax-ymin)(zmax-zmin)/n)1/3
then
a=(xmax-xmin)/pixelsize
b=(ymax-ymin)/pixelsize
c=(zmax-zmin)/pixelsize
then the lattice points are
xmin+pixelsize*(i)=x
ymin+pixelsize*(j)=y
zmin+pixelsize*(k)=z
where i j and k are integers greater than zero and less than or equal to a,b, or c.
 
  • #8
i was wrong with my last post.

basically i want to plot a vector field function to see what it looks like but if i render too many arrows at once i get lag problems
i guess my current solution works for limiting the number of arrows, but its not a very pretty/rigorous/accurate solution.
 

Related to Construct a regular grid in a rectangular box in 3 dimensional space

1. What is a regular grid in a rectangular box?

A regular grid in a rectangular box is a three-dimensional arrangement of evenly spaced points or nodes that form a geometric pattern. It is commonly used in computer graphics, simulations, and scientific visualization to represent data in a structured and organized manner.

2. How is a regular grid constructed in 3 dimensional space?

To construct a regular grid in a rectangular box, the first step is to define the dimensions of the box, including its length, width, and height. Then, the grid spacing or distance between each point must be determined. This can be done by dividing the length, width, and height of the box by the desired number of grid points in each direction. Finally, the points are plotted at the calculated intervals within the box to form the regular grid.

3. What are the advantages of using a regular grid in a rectangular box?

A regular grid in a rectangular box allows for easy and efficient manipulation of data, as it is organized in a structured manner. It also allows for accurate visualization of data and can help identify patterns and trends in the data. Additionally, regular grids can be easily modified or extended to accommodate different data sets.

4. Are there any limitations to using a regular grid in a rectangular box?

While regular grids are useful in many applications, they may not be suitable for representing complex or irregularly shaped data. In these cases, alternative methods such as unstructured grids may be more appropriate. Additionally, the accuracy of the data representation in a regular grid can be limited by the grid spacing and the number of grid points used.

5. What are some practical applications of regular grids in a rectangular box?

Regular grids in a rectangular box have various applications in fields such as engineering, physics, and computer science. For example, they are commonly used in finite element analysis to simulate and analyze complex structures and systems. They are also used in computer graphics to generate three-dimensional objects and in data analysis to visualize and interpret large datasets.

Similar threads

  • Advanced Physics Homework Help
Replies
7
Views
1K
  • Linear and Abstract Algebra
Replies
9
Views
312
  • General Math
Replies
8
Views
2K
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
66
Views
4K
  • General Math
Replies
9
Views
3K
  • Quantum Interpretations and Foundations
Replies
12
Views
949
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
Back
Top