4

I am new to Mathematica, and am unsure on how to start this.

I am working with a triangular lattice $\mathcal{T}$ with basis vectors $(1,0)$ and$\left(-\frac{1}{2},\frac{\sqrt{3}}{2}\right)$, and have a function $f:\mathcal{T}\to\mathbb{R}$ that is defined on this triangular lattice. I want to be able to plot this function on this triangular lattice, any help would be appreciated.

I assume first I have to create the triangular lattice $\mathcal{T}$ as say $\mathtt{T=...}$ and then perform the Plot3D command as follows: $\texttt{Plot3D[f[x,y],{x,y}$\in$T]}$.

The question is then really, how would I generate this point set $\mathtt{T}$.

spaceman
  • 323
  • 1
  • 6

1 Answers1

5

You can do something like this

grid = Flatten[
   Table[x*{1, 0} + y*{-1/2, Sqrt[3]/2}, {x, -Pi, Pi, .25}, {y, -Pi, 
     Pi, .25}], 1];

ListPlot[grid]

enter image description here

z[{x_, y_}] := Sin[x]*Cos[y]
Z = z /@ grid;
data = Append[Transpose[grid], Z];
data = Transpose[data];
ListPlot3D[data]

enter image description here

Derek H
  • 522
  • 3
  • 9