Skip to main content
16 votes

Graphene bilayer rotation

Update: I just noticed you wrote Mathematica 7 and CirclePoints was introduced in v10.1. I am updating my code to eliminate it. I think what remains should work ...
Mr.Wizard's user avatar
  • 273k
14 votes

Graphene bilayer rotation

This solution should work normally on Mathematica 7. It first generates a hexagonal grid and then removes every third point. Finally two grids are combined in one figure. I have fine-tuned the ...
Ray Shadow's user avatar
  • 7,886
13 votes

How to plot $x^2$ over $-5<x<-1\cup1<x<5$

You can also define f conditionally: f[x_] := x^2 /; (-5 < x < -1 || 1 < x < 5)
David Keith's user avatar
  • 4,724
12 votes

How to plot $x^2$ over $-5<x<-1\cup1<x<5$

With reg = ImplicitRegion[-5 < x < -1 || 1 < x < 5, x] or reg = Interval[{-5, -1}, {1, 5}] do ...
corey979's user avatar
  • 24.3k
11 votes
Accepted

How to plot $x^2$ over $-5<x<-1\cup1<x<5$

In V8 and up, one can use ConditionalExpression: ...
Michael E2's user avatar
  • 245k
11 votes

How to plot $x^2$ over $-5<x<-1\cup1<x<5$

Another way is with the option RegionFunction: ...
Greg Hurst's user avatar
  • 36.8k
7 votes
Accepted

How to draw random colorfull domains in a plane?

ListDensityPlot ...
kglr's user avatar
  • 401k
7 votes
Accepted

How to generate randomly curved and twisted strings in 3D?

...
kglr's user avatar
  • 401k
7 votes

Boundary conditions at infinity for 1+2D wave equation in Mathematica 7

Aha, finally here comes a chance to share my implementation of 2nd order absorbing boundary condition (ABC). To understand why the b.c. is implemented in this way, one may refer to Chapter 6 of Lloyd ...
xzczd's user avatar
  • 68.4k
7 votes
Accepted

How can I add a few specific mesh (altitude-like level) curves to a plot?

You can use multiple mesh functions in a plot, each with its own mesh definitions: ...
MarcoB's user avatar
  • 67.7k
6 votes
Accepted

How to introduce random correlations in a 3D uniform distribution of points?

Here is a simple first approach: We seed our "universe" by some random mass points (aka dark matter). Then the next mass point is chosen by an empirical distribution consisting of the ...
Daniel Huber's user avatar
  • 56.3k
6 votes
Accepted

How to define a smooth function of random bumps in a plane?

Pick up the points tt = Table[{x, y, RandomReal[{-1, 1}]}, {x, 0, 5}, {y, 0, 5}]; Interpolate ...
chris's user avatar
  • 23.1k
5 votes

How can I add a few specific mesh (altitude-like level) curves to a plot?

All the methods below add three styled curves, "while all other curves stay in the default style." ContourPlot 1. You can use the options MeshFunctions ...
kglr's user avatar
  • 401k
5 votes

How can I add a few specific mesh (altitude-like level) curves to a plot?

3D Set the Mesh to Mesh -> {{{-1, {Thick, Red}}, {0, {Thick, Green}}, {1, {Thick, Blue}}}} ...
cvgmt's user avatar
  • 84.1k
5 votes
Accepted

How can I improve this code?

...
N.J.Evans's user avatar
  • 5,113
5 votes

How to get fuzzy points in a 3D view?

As OP already suggested, an image sprite based approach could be a solution, except a special rendering option ...
Silvia's user avatar
  • 27.6k
5 votes

What is the right way to rotate an array?

Quarter turn, where m any matrix. Counterclockwise (positive direction): Transpose @ (Reverse /@ m) Clockwise (negative ...
Anders Linner's user avatar
5 votes

How to draw random colorfull domains in a plane?

Thanks @Cham @kglr, the ListContourPlot is a good idea. I think we can also does not change the original points in the plane,so we append the three coordinate with ...
cvgmt's user avatar
  • 84.1k
4 votes

How to draw random colorfull domains in a plane?

Well, I just found a nice trick, but it's not fully satisfying yet, since the cell color isn't random. How can I modify this code to get random colors in all cells? ...
Cham's user avatar
  • 4,133
4 votes

How can I improve this code?

First, get rid of AppendTo and replace it with a preallocation of the array because you know the size in advance. Second, use ...
Domen's user avatar
  • 33.4k
4 votes
Accepted

How to insert variable height in this random bumps function?

Update 2: If you don't need the mesh lines, the surface can be rendered very fast using BSplineSurface + Graphics3D (rather than ...
kglr's user avatar
  • 401k
3 votes

How to simplify this sum of random waves?

To make it more Mathematica-y, we don't even need to define functions to call the parameters/the parts of the individual parameter lists. Instead we can create all the parameters at the same time and ...
NonDairyNeutrino's user avatar
3 votes

Randomly oscillating surface is not working well

The main bug is that you specify randomBumps[t_] := ... instead of randomBumps[t_] = ... This creates a new surface every time the time changes. Further, you have some syntax errors. Here is a ...
Daniel Huber's user avatar
  • 56.3k
2 votes
Accepted

How to add noise to these random straight lines in 3D?

Perhaps ...
kglr's user avatar
  • 401k
2 votes

How to generate randomly curved and twisted strings in 3D?

Here is an attempt where you can specify the curvature and torsion. The start point is chosen at random around the origin. The direction is also random. With these data the Frenet-Serret formula is ...
Daniel Huber's user avatar
  • 56.3k
2 votes
Accepted

How to get the analytical solution or numerical solution of the double integral

Try ...
Ulrich Neumann's user avatar
2 votes
Accepted

How to add random point size to this distribution of 3d points?

...
Daniel Huber's user avatar
  • 56.3k
2 votes

How to make this moving surface a continuous and derivable function?

We need some small modification of the code to plot derivatives ...
Alex Trounev's user avatar
  • 48.8k
2 votes

How to define the density of random 3D points and plot it?

The following is an example based on a uniform distribution of points/galaxies, which can be adapted to any desired distribution. Also, some notes: The code is given here only for educational ...
Hans Olo's user avatar
  • 1,858
2 votes

How to define the density of random 3D points and plot it?

Here is an approach that I hope gets after your objective of I would like to define the local number of particles per unit volume V=ℓ3, on a variable scale ℓ, and plot it as level curves (i.e ...
JimB's user avatar
  • 42.9k

Only top scored, non community-wiki answers of a minimum length are eligible