Wikipedia:Reference desk/Archives/Mathematics/2008 July 22

= July 22 =

Hexagonal lattices and coordinate systems
Please be gentle. It is forty years since I last used Maths in anger, so if this a well known topic, a pointer to a book or web page would be appreciated.

I have developed a coordinate system for working with hexagonal/triangular lattices that allows simple formulae for rotation about a centre, and for mirror image flipping. I use this instead of trig formulae because (a) I cannot afford the inevitable inaccuracies that would creep in in a computer system (b) I need a way that, given a specific point on the lattice, of determining its neighbors.

It works because the two primary axes are at 60 degrees to each other, rather than 90 degrees.

For example, a point at a,b can be rotated 60 deg anticlockwise by

a' = a+b

b' = -a

I cannot find any references to a better system to use. Is there a better one ?

Is there a known way of extending this to three dimensions, for example a lattice built from a face-centered-cubic packing of spheres ?

Dave Joubert 82.71.76.203 (talk) 15:17, 22 July 2008 (UTC)
 * I'm a bit confused and not sure if you made a mistake above? is the rotation about (0,0)?
 * You could use a=i, b=icos60+jcos60
 * ie a is a vector from (0,0) to (x,0) where x is the length of the side of the hexangon
 * b is a vector from (0,0) to (xcos60,xsin60)
 * So a > b > b-a > -a > -b > a-b > a where '>' indicates 'maps onto' by 60 anticlock rotation
 * Is this the same as what you are doing?
 * As for FCC - yes I think so - you need the vector corresponding to the upward diagonal edge of a tetrahedron 'call it c'. Where a and b are the vectors corresponding to the base edges of the tetrahedron
 * ie if Tet. = ABCD a=vector AB, b=vector AC, c=vector AD.87.102.86.73 (talk) 15:36, 22 July 2008 (UTC)
 * I'll let you read that and if it makes sense (it should) then please ask any further questions .. as you've already said using a,b instead of the (1,0) and (1/2,sqrt(3)/2) vectors prevents a computer messing up with rounding errors etc.87.102.86.73 (talk) 15:48, 22 July 2008 (UTC)
 * I believe such things may be described as "lattice vectors" eg http://www.matter.org.uk/diffraction/geometry/lattice_vectors.htm (as an example) I can't find a comprehensive link.87.102.86.73 (talk) 15:58, 22 July 2008 (UTC)


 * One good option that you have is working with complex numbers. There is a complex number $$\tau$$ such that multiplication by $$\tau$$ is the same as rotation by 60 degrees. The triangular lattice (sometimes called the hexagonal lattice) is precisely the set of numbers of the form $$n+m\,\tau$$, where $$n,\,m$$ are integers. The neighbors of a lattice point $$z$$ are precisely the points of the form $$z+\tau^j$$, where $$j=0,1,\dots,5$$. Now, the number $$\tau$$ is equal to $$(1+i\sqrt 3)/2$$, where $$i$$ is the square root of $$-1$$. But you don't need to use this. Since you want exact calculations, you do not want to evaluate the squre root of 3. Instead, you use the fact that $$\tau^2 = \tau-1$$. This lets you multiply any two numbers of the form $$n+m\,\tau$$ exactly, getting again a number of that form. Also, you have $$\tau^{-1}=1-\tau$$, if you ever need a formula for $$\tau^{-1}$$. With regards to the face centered cubic, you would probably want to use matrices. That would be somewhat more complicated. Let's make sure you are first happy with a solution of the two dimensional probalem. Oded (talk) 16:28, 22 July 2008 (UTC)
 * Mmmh - abstracting the method I described above to include complex numbers may be a useful exercise in maths education, but isn't a 'good option' since - as you admit - won't work easily with three dimensions -so why do it???87.102.86.73 (talk) 16:47, 22 July 2008 (UTC)
 * Complex numbers give a conceptual framework, which is useful for understanding, and that's important. One way to think of complex number is as matrices of a certain form. In that sense, the approach does generalize. Oded (talk) 16:59, 22 July 2008 (UTC)
 * I agree that we are all saying essentially the same thing, but in different words. Oded (talk) 17:07, 22 July 2008 (UTC)

Hmm.. I will have to think about using complex numbers since the computer language I am using is restricted.

As you might gather, all of this probably better explained with a diagram (for my own good anyway). I will go away and do a diagram and come back here with a reference to that web page. I suspect what I am doing is manipulating the coefficients of a formula.

Dave —Preceding unsigned comment added by 82.71.76.203 (talk) 16:42, 22 July 2008 (UTC)


 * You don't need software or hardware support for complex numbers in order to implement this. You can represent a number of the form $$n+m\,\tau$$ as a pair of integers $$(n,m)$$. Since you know how to do your operations on such pairs, that is enough. Oded (talk) 16:59, 22 July 2008 (UTC)

Diagram now up at There is obviously some connection between the simple arithmetic on the coordinates and the vector discussion above, but I am not enough of a mathematician to work out what it is. An understanding of the maths will hopefully make rotation about the other axes easy, and offer a path to doing this in 3D. Dave —Preceding unsigned comment added by 82.71.76.203 (talk) 18:03, 22 July 2008 (UTC)


 * Yes. One way you could understand it is via the complex numbers. To figure out what a specific reflection or rotation does, you can check what it does to $$\tau$$ and to $$1$$. For example, the rotation about the line that is at 30 degrees from the x axis takes $$\tau$$ to $$1$$ and takes $$1$$ to $$\tau$$. Therefore, with the above notation it takes $$(n,m)$$ to $$(m,n)$$.


 * What is precisely that you want to do in the 3 dimensional case. Is it that you need to implement the following operations:
 * List the neighbors of any given lattice point $$v$$
 * For each of several (which?) symmetries $$S$$ of the lattice (which preserve 0?) and for each lattice point $$v$$ to be able to calculate the image lattice point $$Sv$$.
 * Oded (talk) 18:29, 22 July 2008 (UTC)


 * Now I've seen the diagram I see that you are right (and you can ignore what I said about a mistake above), and that the equations I gave above match your results as well eg a > b > b-a > -a > -b > a-b > a where '>' indicates 'maps onto' by 60 anticlock rotation.
 * So the point 2,4 ie a=2 b=4 gives
 * a=2 becomes b=2 (a 'maps onto' b from above)
 * And b=4 becomes 4b-4a (from b 'maps onto' b-a) ie b becomes b-a, so b+b becomes 2b-2a etc
 * So from the new things you get a total b of 6 (4b+2b) and a total a of minus 4 .. so the point is (-4,6) (as you say).
 * This should be simple enough for you to work out why they work.. Question can you remember any algebra?
 * eg can you solve x+y=3 and x+2y=7 getting x and y?
 * Also can you remember any vectors? they're lines that you travel along. eg the vector (1,1) would be across 1 up 1 and the vector N(1,2) would be across N and up 2N - you're definatetly going to need something like this to get an explanation for yourself.
 * ((Also it will be very helpful (but maybe not totally necessary) for you to be able to work out say how a point (a,b) reflects in a line y=4x=5 (for example).. Finding a reflection of Point A means you need to find a point on the reflection line (call it B) that gives the line AB at right angles to the reflection line.. ))


 * Look at the point 2,4 on your diagram - can you see that it can be made from 2 along B=0 and 4 along A=0, (you probably already know this). BUT each step along A=0 is equal to half a step along B=0 and a fraction of a step upwards.
 * So if you convert steps right (A+B/2) and steps up FxB (F is the fraction) it should be obvious that on refection the point is at steps right (A+B/2) and steps down FxB (F is the fraction) -
 * try to write equations for x (steps right) and y (steps up) in terms of A and B (F will also be in but don't worry about calculating it) . Then solve the equations - that is rearrange them to get A and B in terms of x and y eg A=.... B=..., doing that should help you work out why reflection in B=0 does what it does to A and B why first expressing them in turns of x and y, doing the reflection and reconverting.. Good luck. I recommend you try one of the reflections first, then assuming you can crack it, try the rotations.. Did any of that help?87.102.86.73 (talk) 18:59, 22 July 2008 (UTC)

OK, I had not thought of super-imposing 'normal' right-angle axes on top of my own 60deg axes. I will try that approach to solve some of the reflections that I had not seen easy solutions for. Being able to work out logically why this all works, might help me think clearly about the 3D case. At least in 2D there are only 6 axes of reflection symmetry to worry about!! Unfortunately, right now I need to go and earn my living.... —Preceding unsigned comment added by 82.71.76.203 (talk) 19:49, 22 July 2008 (UTC)
 * Yes use right angles for reflections, it looks like your general method is right - that is to use sums of A and B .. (though if you get stuck for a formula you can always go back to x and y coordinates to derive a formula)
 * Using A,B and C for 3d where C is the side of a tetrahedron should simplify things for you.

B.             .|. . | .           .  |  .           .   |   .          .    |    .         .     |     .        .      |      .     O .................C               D

Remember that OB - 1/2 OC = DB (and similar for the line at right angles to OB going through C) - that you will probably need to work out reflections at 0,90 degrees.87.102.86.73 (talk) 21:01, 22 July 2008 (UTC)


 * On the subject of extending your coordinate system to 3D, the obvious approach is to add "C" such that C is 60 degrees to both A and B (I think this is the same as the tetra hedron above). (In your diagram, B is the the East, A is to the ~NorthEast and C would be to the EastNorthEast and "up a bit". Then the same equations used for operations on A & B with constant C would presumably apply to B&C with constant A and to C&A with constant B. It probably matters that you use C&A rather than A&C but I haven't investigated this yet. If you can split your operations up into several operations, each within a plane then the 3D manoeuvres will fall into place. -- SGBailey (talk) 09:25, 23 July 2008 (UTC)

I have had one half of the 3D system in place for a while, namely the easy translation bit from lattice coordinates to x,y,z coordinates, using a face-centered-cubic packing. I 'just' need to do two bits; understand exactly why the rotations and reflections work as they do in 2D, and to extend the operations to 3D. Because there are so many more axes of symmetry in 3D, if I do not understand the principles I will be swamped. Rant: Unfortunately, I abandoned maths for computer science too early; my lecturers at university never managed to explain why integration and differentiation were important and why imaginary numbers were important. With hindsight, if they could have shown us students the exciting far edges of maths, and explained that you cannot get there without understanding whether a surface is differentiable or not, I may have stuck with it a bit longer. They managed to make something that was enjoyable at school into something extremely hidebound, and maths could not compete with computer science.... —Preceding unsigned comment added by 82.71.76.203 (talk) 11:54, 23 July 2008 (UTC)
 * Hopefully you should be able to prove the reflection now, for proof of why the rotations work I'd recommend converting temporarily in to x,y coordinates.. this section Rotation_(mathematics) contains the equations you need and hopefully understand..
 * For FCC it's work noting that this is a very symmetric crystal structure (more so than HCP) and that the symmetry relations you find in 2d are pretty much continue in 3d.. Returning again to the tetrahedron - if you make a triangle in the flat plane part of a tetrahedron (the base of) in FCC then any reflection/rotation symmetry will be repeated on all the other 3 faces of that tetrahedron! Anyway I leave it to you to find that out - but be warned thinking in 3d can be most confusing, (unless you've got a natural skill for it which I haven't).
 * Come back if you get stuck.87.102.86.73 (talk) 12:37, 23 July 2008 (UTC)

Yes.I am clear in my head what I need to do for my own understanding:

1) Show the symbolic relationship between (a,b) in my slanted axes vs (x,y) in normal cartesian coords

2) Do a symbolic rotation in cartesian space

3) Convert back to my slanted axes

By implication (because it already works) all the cos and sin components in 30 and 60 degrees during this process will drop out, and I will be left with simple addition/subtraction in the slanted coordinate system. Someone else could probably do this more elegantly with vectors and imaginary numbers, but my maths is not up to tackling it than way!

Then I can do the same for reflection, and I will really understand why slanted axes are a shortcut as opposed to finding this out by accident and observation.

I should then have a good understanding of how to do this in 3D; If I find I still need help, I will come back. PS: I initially chose FCC because the symmetries were more obvious; by good luck FCC makes more sense in the applicable domain than HCP does. —Preceding unsigned comment added by 82.71.76.203 (talk) 15:28, 23 July 2008 (UTC)

More on Continuity
On which points $$f(x)=floor(x^2)\sin(\pi x)$$ is discontinuous and how to prove it? I mean, I can approximate the points of discontinuities by graphing but how to find them analytically?--76.79.202.34 (talk) 20:41, 22 July 2008 (UTC)
 * Floor is discontinuous at integers, so f could be discontinuous whenever x^2 is an integer, so when x is the square root of any integer. We then need to check if the sine part gets rid of any of those discontinuities. It will be 0 whenever x is an integer, which I think gets rid of the discontinuities there, but the others will remain, so it is discontinuous at any non-integer square root of an integer. To prove this all rigorously, you need to look at the definition of continuity. --Tango (talk) 20:50, 22 July 2008 (UTC)
 * I'm not sure what your formula means. Tango seems to be assuming you mean $$f(x)=\lfloor x^2 \rfloor \sin (\pi x)$$, but you might mean $$f(x)=\lfloor x^2 \sin (\pi x) \rfloor$$. Algebraist 20:56, 22 July 2008 (UTC)
 * With the brackets placed the way they are, I think only the former is a reasonable interpretation. --Tango (talk) 21:55, 22 July 2008 (UTC)
 * So it is. My glasses must have been malfunctioning or something. Algebraist 18:02, 23 July 2008 (UTC)

Tango is correct, the floor function is applied on to the x^2 term. Thanks Tango, that seems to make perfect sense.--76.79.202.34 (talk) 21:40, 22 July 2008 (UTC)
 * It may not be correct, though, I haven't actually got a pen and paper and double checked the "sin=0 => continuous" bit, but intuitively, it seems to work. --Tango (talk) 21:55, 22 July 2008 (UTC)
 * It works. Function tending to zero * bounded function = function tending to zero. Algebraist 21:58, 22 July 2008 (UTC)