# Thread: Calculate Torus dimentions to align to a square grid.

1. ## Calculate Torus dimentions to align to a square grid.

I am using a program to create a torus which ideally should align to a square grid. The basic outline can be seen here:
http://img251.imageshack.us/img251/8...ussettings.png

The reason is would be nice to have it align to the grid is so that when the torus is rendered there is no light bleeding from tiny mis-alignments. If u want to know more:
Displacement light bleed. - Steam Users' Forums

I'm not sure its even possible to do make every point align to the grid, but I would like to know how to calculate this.

I have a cookie waiting for anyone who helps.

2. What do you mean by "every point align to the grid"? If the torus is the one in the popup box you have there, and the grid is the grid in the upper right corner, I'd say it might be possible to have eight points on the torus lie directly on top of grid intersection points. Those eight points would be the north, south, east, and west of the inner and outer radii. If 4096 is the width and height of the grid, you'd want to have the inner radius be 1024, and the outer radius 2048. Then you'd center the torus at the center of the grid.

I have no idea if this is what you had in mind, but it's what came to my mind.

3. Originally Posted by Ackbeet
What do you mean by "every point align to the grid"? If the torus is the one in the popup box you have there, and the grid is the grid in the upper right corner, I'd say it might be possible to have eight points on the torus lie directly on top of grid intersection points. Those eight points would be the north, south, east, and west of the inner and outer radii. If 4096 is the width and height of the grid, you'd want to have the inner radius be 1024, and the outer radius 2048. Then you'd center the torus at the center of the grid.

I have no idea if this is what you had in mind, but it's what came to my mind.
By point I mean vertex, if u have a cube each corner has 3 vertex joining together at the same spot. The term plane as I understand means a flat surface which extends to infinity. The grid size is 1 unit at its smallest, and goes up by the power of 2 (1,2,4,8,16,32 ect).

You are correct when I put 1024 in as the radius ( the outer radius is 2048 as we set the diameter to 4096 ), I get 8 points on the grid. However there are actually 4 different radius measurements: the toroid has walls of a finite depth. In the screenshot "wall width" is set to 20. The inner edge of the inner wall is on the grid and also the outer edge of the outer wall, when the radius is set to 1024.

The rotation sides in the screenshot, allows some control over where the vertex corresponding to the plane angled at for example 45 degrees joins the vertex corresponding to the torroid walls. If planes are angled every 45 degrees that would give 2 rotation sides in 90 degrees and 8 in total.

I tried having 8 rotation sides, it didn't align the 45 degree planes to the grid.

Getting as many vertex on the grid as possible is helpful, as I can edit the vertex manually onto the grid. There is a similar problem in the z-axis where you have 2 walls forming the boundary. This is set by the 1024 radius and again has the outer edge of the outer wall and the inner edge of the inner wall on the grid.

I'm trying to put into words what I am zooming into in the editor, this is where video tutorials have the advantage over written matter.

The only problem with setting the inner radius to half of the outer radius is that the proportions are off. If u imagine an underground train the distance between the inner and outer radius is small compared to the outer radius with respect to the origin. The tunnel cross sectional area needs to be approximately 4 times that of a regular tunnel due to the game mechanics (the player is viewed from a camera above him angle at 60 degrees). FYI although the cross-section is a square it can be "sub-divided" into a close approximation of a circle.

4. Try setting the wall width equal to a power of 2, say, 16. What does that give you?