Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Staff Picks sorted by active[WWS21] Defect movement in lattice rewriting systems
https://community.wolfram.com/groups/-/m/t/2164049
![enter image description here][1]
&[Wolfram Notebook][2]
Code: https://github.com/taliesinb/LatticeRewriting
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=image%287%29.png&userId=2161364
[2]: https://www.wolframcloud.com/obj/65c63b92-6ee9-44fc-b0b6-08a8524da33c
[Original]: https://www.wolframcloud.com/obj/da875739-a182-4834-aaf4-3928a539f7c4Keith Patarroyo2021-01-15T18:52:23ZTilings and constraint programming
https://community.wolfram.com/groups/-/m/t/2135869
Introduction
------------
The goal of this post is to start from images like this example one :
![Girl3][1]
and generate pictures like:
![Girl3Gray][2]
or
![Girl3Color][3]
Mathematica at least 12.1 will be required since Mixed Integer programming is used.
Explanation
-----------
Let's take the first image (black and white) as an example.
Let's assume we have a collection of 16 tiles:
![GrayTiles][4]
The problem to solve is how to place the tiles on the picture so that the gray content of a tile is close to the gray content of the picture below it and at the same time the topological constraints are satisfied.
By topological constraints, I mean that the tiles must be compatible.
This is allowed:
![Allowed][5]
This is forbidden because the dark horizontal band is continuing as a white horizontal band.
![Forbidden][6]
We are going to translate this problem into a set of equations on integer variables and with a linear cost function to optimize. The final problem will be solved with the LinearOptimization function from Mathematica 12.1.
Each pixel of the image is encoded by a vector ![eq1][7] because there are 16 different tiles in this example. The components of the vector can be either 0 or 1.
This is expressed as:
VectorLessEqual[{0, v}], VectorLessEqual[{v, 1}], v \[Element] Vectors[nbTiles, Integers]
For each pixel, only one tile can be used. We cannot put several tiles on a pixel but only choose one and only one.
If we use the constraint:
![eq2][8]
then we express that only one tile can be used. Indeed, since the component are integers and equal to 0 or 1, then the only way to satisfy this equation is that one of the components, and only one, is equal to one.
Expressing the topological constraints is similar.
We have equations like:
![eq3][9]
This equation is describing a relationship between pixel (x,y) and pixel (x+1,y).
The values on left and right side can either be 0 or 1 (at same time). When zero it means : none of the tiles is used. When one, it means one of the tile is used. So, the translation of the equation is:
If the tile 0,3 or 5 are used at pixel (x,y) then the tiles 3,6,9 or 11 must be used at pixel (x+1,y).
(I have not checked if it makes sense with the set of tiles I am using as example. The constraints for those tiles are probably different.).
To describe the topological constraint of the tiles, we have functions like:
rightSide[tileA[{a_,b_,c_}]] :={b,c};
This is giving a key describing the right side of the tile. Those keys are then used in associations to build the topological constraints. The key can be anything so if you want to add new tiles, you can just use the key you want to describe the sides of your tiles.
The generic function rightSide must be extended with new cases when new tiles are added.
Then, we need to express how good the tiles are approximating the original picture.
For this, an error function is created. It is a sum of terms:
![eq4][10]
It means that if the tile i is selected for pixel (x,y) then the approximation error is `Subscript[f, k]`
The function averageColor must be extended with new tiles. It returns the color content of a tile : a RGBColor. The code is using a color distance to compute the errors.
That's why the input picture is always converted to RGB and the alpha channel removed.
So, finally we have translated our problem into a set of integer constraints and with a linear cost function to optimize. It is a mixed integer programming problem which can be solved with LinearOptimization.
The tiles must be displayed. It is done by the function tileDraw and the tile is drawn in a square from (0,0) to (1,1) corners.
The code is rasterizing those graphics into 50x50 pixel images.
I have had lots of problems with those pictures due to rounding errors ... probably due to the very old GPU on my very old computer.
So I tuned the vector code assuming the final tile image is 50x50 pixels. Now the pictures are well aligned, there is no more one row or one column of wrong pixels on the boundary of the tiles.
But this may cause a problem on your configuration. So, if the tile pictures are not rendering correctly on your side, you'll need to tune my vector graphic code again.
If the picture is too big, solving the full mixed integer programming problem may take too long. But we can solve a sub-optimal problem. We divide the picture into sub-pictures and solve the problem on each sub-picture then we recombine the solutions. For it to work : we must add new constraints to express compatibility between the pictures.
For instance, the left side of a picture at (row,col) must be compatible with the right side of the picture at (row,col-1). So, the problem must be solved in a given order so that the constraints can be propagated from one sub-picture to the other.
For some tiles, the sub-optimal solution can be very good from an artistic point of view (the dark tiles below are working well). For other tiles (the smith tiles in the notebook) either the sub-optimal problem cannot always be solved (because the constraints coming from the previous pictures can't be satisfied) or the sub-optimal problem will look bad from time to time.
So this idea of using sub-picture is really dependent on the kind of tiles used. You need to experiment. But it is art after all.
Example of use
--------------
First, we get an example picture:
srcImage = ImageCrop[ExampleData[{"TestImage", "Girl3"}], {190, 270}]
The picture is resized, converted to RGB and any alpha channel removed.
imgToAnalyze =
ImageResize[
ImageAdjust[
RemoveAlphaChannel[ColorConvert[srcImage, "RGB"], Black]], {50,
Automatic}]
For the dark tiles (knots), we decide to only use gray levels. First color is the background of the tiles. Other colors are for the circles and vertical and horizontal bands.
tileData =
mkDarkTiles[RGBColor[
0.5, 0.5, 0.5], {RGBColor[0., 0., 0.], RGBColor[1., 1., 1.]}];
It gives a total of 16 tiles. The more tiles, the more difficult it is to solve the problem. 16 is ok on my old computer.
tileData["allTilesImg"] // Length
The problem is solved on 15x15 sub pictures.
solution = partitionSolve[tileData, imgToAnalyze, 15];
The final picture is generated from the tiles and the solution.
img = createPict[tileData, solution];
And you'll get:
![Girl3Gray][2]
Have fun ! I hope the vectorial code will not have to be tuned to generate the tile pictures (rounding errors).
The notebook is attached to the post.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Girl3.png&userId=89693
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Girl3Gray.png&userId=89693
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Girl3Color.png&userId=89693
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Tiles.png&userId=89693
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Allowed.png&userId=89693
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Forbidden.png&userId=89693
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eq1.png&userId=89693
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eq2.png&userId=89693
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eq3.png&userId=89693
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=eq4.png&userId=89693
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=LenaGray.png&userId=89693Christophe Favergeon2020-12-11T16:08:18ZPredicting COVID-19 using cough sounds classification
https://community.wolfram.com/groups/-/m/t/2166833
&[Wolfram Notebook][1]
[Original]: https://www.wolframcloud.com/obj/dfed8d32-9a69-4246-89ed-2a471c343a30
[1]: https://www.wolframcloud.com/obj/569968ad-436d-4694-adf1-e4b03148e3a2Siria Sadeddin2021-01-18T22:46:11ZRational tetrahedra: edge lengths from given angles
https://community.wolfram.com/groups/-/m/t/2169279
At stackexchange I [posted a question][1]:
> In the paper [Space Vectors Forming Rational Angles][2] a special set
> of tetrahedra is mentioned.
>
> "The remaining three are in the R-orbit of the tetrahedron with
> dihedral angles (π/7, 3π/7, π/3, π/3, 4π/7, 4π/7)."
>
> What is a set of edge lengths or vertices for this tetrahedron? I've
> written a function that converts [edges to angles][3], but I need the
> reverse.
I found the tetrahedron. First, the angles need to be arranged so that a particular determinant is zero. Here's one arrangement that works.
{a, b, c, d, e, f} = {\[Pi]/7, \[Pi]/3, (4 \[Pi])/7, (4 \[Pi])/7, \[Pi]/3, (3 \[Pi])/7};
RootReduce[Det[{{-1, Cos[a], Cos[b], Cos[c]},
{Cos[a], -1, Cos[d], Cos[e]},
{Cos[b], Cos[d], -1, Cos[f]},
{Cos[c], Cos[e], Cos[f], -1}}]]
Then I used [TetrahedronEdgeAngles][4] on two set points and two random points, their distances, millions of random points, and annealing to boil things down to exact values.
vert={{-(1/2),0,0},{1/2,0,0},{-0.0678\[Ellipsis],0.552\[Ellipsis],-0.126\[Ellipsis]},{0.0678\[Ellipsis],0.552\[Ellipsis],0.126\[Ellipsis]}};
Graphics3D[Tube/@Subsets[vert,{2}]]
![seventh tetrahedron][5]
I'm not sure how to do the R-orbit, but that's the first one. I'd like to get all of the rational tetrahedra and put them into something like [Solid and Dihedral Angles of a Tetrahedron][6].
A notebook with this tetrahedron is below
&[Wolfram Notebook][7]
[1]: https://math.stackexchange.com/questions/3993429/given-dihedral-angles-find-a-set-of-edges
[2]: http://www-math.mit.edu/~poonen/papers/space_vectors.pdf
[3]: https://resources.wolframcloud.com/FunctionRepository/resources/TetrahedronEdgeAngles/
[4]: https://resources.wolframcloud.com/FunctionRepository/resources/TetrahedronEdgeAngles/
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=seventh.png&userId=21530
[6]: https://demonstrations.wolfram.com/SolidAndDihedralAnglesOfATetrahedron/
[7]: https://www.wolframcloud.com/obj/87b6062b-40b3-45af-a67f-267aae7bb7a9Ed Pegg2021-01-21T16:00:11ZDrawing a chess position from FEN (Forsyth–Edwards Notation)
https://community.wolfram.com/groups/-/m/t/2164714
![enter image description here][1]
I'm sure there have been many proposals on how to do this. I gave it a try, and after a few painful attempts I came up with a visually decent result, without too much code (IMHO). Also I really wanted to use unicode symbols, not drawing of pieces found on the web.
&[chess.nb][2]
TODO:
- Avoid using a hard-coded font size ;
- White pieces should not look "transparent" on a dark square.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2021-01-20at11.26.07AM.jpg&userId=11733
[2]: https://www.wolframcloud.com/obj/71555ba7-132e-4569-913e-fa3e69184a85Lucien Grondin2021-01-16T13:12:04ZCOVID19 Tokyo per days of the week
https://community.wolfram.com/groups/-/m/t/2133807
*MODERATOR NOTE: coronavirus resources & updates:* https://wolfr.am/coronavirus
----------
![enter image description here][1]
Seven curves represent number of confirmed COVID-19 cases in each day of the week through the year 2020, with top 4 points highlighted on each curve
(In Japanese)２０２０年東京の新規感染者数を曜日ごと（月曜から日曜までの７種類の曲線）に図示したグラフ。各曲線にはＴＯＰ４のランキングがマークされている。
-------------------------------------------
&[Wolfram Notebook][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=7263tokyo.gif&userId=1875183
[2]: https://www.wolframcloud.com/obj/wolfram-community/Published/covid19TokoyoWeek3_1.nb
[Original notebook]: https://www.wolframcloud.com/obj/i-maruyama/Published/covid19TokyoWeek2.nb
[Original lead image]: https://community.wolfram.com//c/portal/getImageAttachment?filename=tokyo.gif&userId=1875183
[Original lead image2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Lead_figure4.gif&userId=20103Isao Maruyama2020-12-09T13:26:27ZMaking graphs over system dynamics models
https://community.wolfram.com/groups/-/m/t/2137836
&[Wolfram Notebook][1]
[Original]: https://www.wolframcloud.com/obj/antononcube/Published/Making-Graphs-over-System-Dynamics-Models.nb
[1]: https://www.wolframcloud.com/obj/wolfram-community/Published/Making-Graphs-over-System-Dynamics-Models_2.nbAnton Antonov2020-12-14T16:07:09ZSolve a Euro Math Cup 2020 Problem with GeometricScene
https://community.wolfram.com/groups/-/m/t/2168033
![enter image description here][1]
&[Wolfram Notebook][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2021-01-19_19-16-12.gif&userId=23928
[2]: https://www.wolframcloud.com/obj/shenghuiy/Published/EuroMathCup2020.nbShenghui Yang2021-01-20T04:18:41Z[GIF] Visualizing Interstellar's Wormhole: from article to programming
https://community.wolfram.com/groups/-/m/t/852052
*Click on image to zoom. Press browser back button to return to the post.*
----------
[![enter image description here][5]][5]
Let me start off by saying that I know almost nothing about general relativity, but I thought it was really fun translating the equations presented in [this paper](http://arxiv.org/abs/1502.03809) by Oliver James, Eugenie von Tunzelmann, Paul Franklin, and Kip Thorne into notebook expressions.
Embedding Diagrams
==================
The paper gives some really cool figures to show the curvature of 4-dimensional spacetime in the region around a wormhole. The physics of the wormhole is essentially described by three parameters:
1. $\rho$ - the radius of the wormhole
2. $a$ - the length of the wormhole
3. $\mathcal{M}$ - a parameter describing the curvature, described in the paper as the "gentleness of the transition from the wormhole's cylindrical interior to its asymptotically flat exterior"
To look at the curvature for a given set of parameters, we only really care about the ratios $a/\rho$ and $\mathcal{M}/\rho$.
Taking equations (5) and (6) from the paper, we can plot the curvature for any pair of these parameters using cylindrical coordinates. Since the $z$ coordinate is described found via numerical integration, I chose to speed up the `ParametricPlot3D` by first forming an interpolating function.
embeddingDiagram[a_, M_, lmax_: 4] := Module[{? = 1, z, zz, x, r},
x[l_] := (2 (Abs[l] - a))/(?*M);
r[l_] := ? +
UnitStep[
Abs[l] - a] (M (x[l]*ArcTan[x[l]] - 1/2 Log[1 + (x[l])^2]));
z[l_] :=
NIntegrate[Sqrt[
1 - (UnitStep[
Abs[ll] -
a] (2 ArcTan[(2 (-a + Abs[ll]))/(M ?)] Sign[
l])/?)^2], {ll, 0, l}];
zz = Interpolation@({#, z[#]} & /@ Subdivide[lmax, 20]);
ParametricPlot3D[{{r[l] Cos[t], r[l] Sin[t], zz[l]}, {r[l] Cos[t],
r[l] Sin[t], -zz[l]}}, {l, 0, lmax}, {t, 0, 2 ?},
PlotStyle -> Directive[Orange, Specularity[White, 50]],
Boxed -> False,
Axes -> False,
ImageSize -> 500,
PlotPoints -> {40, 15}]
]
and here are three examples shown in the paper,
embeddingDiagram[0.005, 0.05/1.43]
embeddingDiagram[0.5, 0.014]
embeddingDiagram[0.5, 0.43, 10]
![enter image description here][2]
Tracing rays through the wormhole
=================================
The appendix to the paper describes a procedure for creating an image taken from a camera on one side of the wormhole. The procedure involves generating a map from one set of spherical polar coordinates (the "camera sky") to the "celestial spheres" describing the two ends of the wormhole.
First a location is chosen for the camera, then light rays are traced backwards in time from the camera to one of the two celestial spheres. This ray tracing involves solving 5 coupled differential equations back from $t=0$ to minus infinity (or a large negative time).
For this I use [`ParametricNDSolve`](http://reference.wolfram.com/language/ref/ParametricNDSolve.html). The functions being solved for are the spherical coordinates of the light rays and their momenta.
The parameters for `ParametricNDSolve` are the wormhole parameters listed above, the camera's position `{lcamera, ?camera, ?camera}` and the "camera sky" coordinates, used to build the map. Rather than walk through their derivation (again, not a cosmologist), I cite the paper for the equations given below:
rayTrace = Module[{
(* auxilliary variables *)
nl, n?, n?, p?,
bsquared, M, x, r, rprime,
(* parameters for ParametricNDSolve *)
?camsky, \
?camsky, ?, lcamera, ?camera, ?camera, W, a,
(* time dependent parameters to be solved for *)
l, ?, ?, pl, p?,
(* the time variable *)
t
},
(* Eq. (7) *)
M = W/1.42953;
(*Eq. 5 *)
x[l_] := (2 (Abs[l] - a))/(?*M);
r[l_] := ? +
UnitStep[
Abs[l] - a] (M (x[l]*ArcTan[x[l]] - 1/2 Log[1 + (x[l])^2]));
rprime[l_] :=
UnitStep[
Abs[l] -
a] (2 ArcTan[(2 (-a + Abs[l]))/(M ?)] Sign[l])/?;
(* Eq. A.9b *)
nl = -Sin[?camsky] Cos[?camsky];
n? = -Sin[?camsky] Sin[?camsky];
n? = Cos[?camsky];
(*Eq. A.9d*)
p? = r[lcamera] Sin[?camera] n?;
bsquared = (r[lcamera])^2*(n?^2 + n?^2);
ParametricNDSolveValue[{
(* Eq. A.7 *)
l'[t] == pl[t],
?'[t] == p?[t]/(r[l[t]])^2,
?'[t] == p?/((r[l[t]])^2 (Sin[?[t]])^2),
pl'[t] == bsquared*rprime[l[t]]/(r[l[t]])^3,
p?'[t] ==
p?^2/(r[l[t]])^2 Cos[?[t]]/(Sin[?[t]])^3,
(* Eq. A.9c *)
pl[0] == nl,
p?[0] == r[lcamera] n?,
(* Initial conditions, paragraph following Eq. A.9d *)
l[0] == lcamera,
?[0] == ?camera,
?[0] == ?camera
},
{l, ?, ?, pl, p?},
{t, 0, -10^6},
{?camsky, ?camsky,
lcamera, ?camera, ?camera, ?, W, a}]];
Now to use the `rayTrace` function - we want to build up an array of values for which we can use a `ListInterpolation` function to map any direction in the camera's local sky to coordinates in one of the celestial spheres. Exactly which celestial sphere is determined by the sign of the lenght coordinate, `l`. The size of the array is very important. I find that it is important to use an odd number of array elements, or you'll end up with an ugly vertical line in the center of your image.
generateMap[nn_, lc_, ?c_, ?c_, ?_, W_, a_] :=
ParallelTable[{Mod[#2/?, 1], Mod[#3/(2 ?), 1], #1} & @@
Through[rayTrace[?, ?, lc, ?c, ?c, ?,
W, a][-10^6]][[;; 3]], {?,
Subdivide[?, nn]}, {?, Subdivide[2 ?, nn]}]
Finally you need a function to transform the two input images using the map generated by the above function. I would be very happy if someone could suggest a method to do this better - perhaps using `ImageTransformation`? I was able to make something work with `ImageTransformation` but it was much less efficient than this. Essentially, `ImageTransformation` can map pixels from one part of an image to another, but they won't grab pixels from another image. You could create a composite image, with the two stacked on top of each other, or you could use the transformation function on each one separately and then combine them.
blackHoleImage[foreground_, background_, map_] :=
Module[{raytracefunc, img1func, img2func, nrows, ncols, mapfunc},
{nrows, ncols} = Reverse@ImageDimensions@foreground;
raytracefunc =
ListInterpolation[#, {{1, nrows}, {1, ncols}},
InterpolationOrder -> 1] & /@ Transpose[(map), {2, 3, 1}];
img1func =
ListInterpolation[#, {{0, 1}, {0, 1}}] & /@
Transpose[(foreground // ImageData), {2, 3, 1}];
img2func =
ListInterpolation[#, {{0, 1}, {0, 1}}] & /@
Transpose[(background // ImageData), {2, 3, 1}];
mapfunc[a_, b_, x_ /; x <= 0] := Through[img2func[a, b]];
mapfunc[a_, b_, x_ /; x > 0] := Through[img1func[a, b]];
Image@Array[
mapfunc @@ Through[raytracefunc[#1, #2]] &, {nrows, ncols}]
]
Low-resolution test
===================
To generate a map using `nn=501` takes about 15 to 20 minutes on my PC, so it's no good for testing the effects of various parameters. So we'll make a much smaller map, and the quality of the image will be lower. We can grab a couple of images from the cite listed in the paper,
foreground=Import["http://www.dneg.com/wp-content/uploads/2015/02/InterstellarWormhole_Fig6b.jpg"];
background=Import["http://www.dneg.com/wp-content/uploads/2015/02/InterstellarWormhole_Fig6a.jpg"];
and make a 101 by 101 map in under a minute:
map1 =
generateMap[101, 6.0, ?/2, 0, 5.0, 0.07, 2.4]; // AbsoluteTiming
(* {36.2135, Null} *)
Here I've taken some some paramters I think make a cool picture ($ \rho = 5.0$, $a = 2.4$, $W = \mathcal{M}/1.43 = 0.07$) and put the camera at $\{l, \theta, \phi\} = \{ 6, \pi/2, 0 \}$. Since the map is low resolution, I can reduce the resolution of the images to get a quick result,
blackHoleImage[ImageResize[foreground, 500],
ImageResize[background, 500], map1]
[![enter image description here][3]][4]
But if you set `nn=501` and don't resize the images you get
![enter image description here][5]
Alien invasion
==============
Have you ever read the *Commonwealth Saga* by Peter F. Hamilton, wherein an alien invades human-held territories via wormhole with the intent of exterminating our species?
![Mathematica graphics](http://i.imgur.com/DQ33Qkh.gif)
[here](https://www.dropbox.com/s/f9zu8eyjnxx77jj/out.mp4?dl=1) is a better quality, lower filesize mp4 of the above animation. To make this one, I varied the wormhole width from 0 up to 5, then used `ImageCompose` to add in [this](http://www.wpclipart.com/cartoon/aliens/alien_ship/flying_saucer_2_T.png) stock image flying saucer, then shrunk the wormhole back to zero width.
Unfinished tasks
--
I think it would be very interesting to take the result of `rayTrace` and plot it on top of the embedding diagram, but I haven't quite figured this out.
I also think it would be pretty neat to take a terrestrial picture (say of the White House), and have a wormhole open up in the background. Finally, I would be very pleased to figure out how to put the wormhole at any position in an image I want, rather than just the center.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=frame_100.png&userId=130877
[2]: http://i.stack.imgur.com/f3drY.png
[3]: http://i.stack.imgur.com/cvKBK.png
[4]: http://i.stack.imgur.com/cvKBK.png
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=frame_100.jpg&userId=20103Jason Biggs2016-05-06T13:44:35Z[UPDATES] Resources For Novel Coronavirus COVID-19
https://community.wolfram.com/groups/-/m/t/1872608
*Short URL to share this post*: https://wolfr.am/coronavirus
***JOIN*** *our* ***Medical Sciences*** *group for the latest updates & best networking*: https://wolfr.am/MedicalSciences
----------
This post is intended to be the hub for Wolfram resources related to novel coronavirus disease COVID-19 that originated in Wuhan, China. The larger aim is to provide a forum for disseminating ways in which Wolfram technologies and coding can be utilized to shed light on the virus and pandemic. Possibilities include using the Wolfram Language for data-mining, modeling, analysis, visualizations, and so forth. Among other things, we encourage comments and feedback on these resources. Please note that this is intended for technical analysis and discussion supported by computation. Aspects outside this scope and better suited for different forums should be avoided. Thank you for your contribution!
[![enter image description here][1]](https://www.wolframcloud.com/obj/examples/COVID19China)
[![enter image description here][2]](https://www.wolframcloud.com/obj/examples/COVID19US)
[![enter image description here][3]](https://www.wolframcloud.com/obj/examples/COVID19World)
[![enter image description here][4]](https://www.wolframcloud.com/obj/examples/COVID19Gene)
[![enter image description here][5]](https://www.wolframcloud.com/obj/examples/COVID19Patient)
[![enter image description here][6]](https://www.wolframcloud.com/obj/examples/COVID19Resources)
[![enter image description here][7]](https://www.wolframcloud.com/obj/examples/COVID19Dashboard)
*Short URL to share dashboard:* https://wolfr.am/COVID19Dashboard
## ________________________________________
## FEATURED CONTENT
- [COVID-19 Livestream Notebook March 24][10] by Stephen Wolfram
- [Agent-Based Networks Models for COVID-19][11] by Christopher Wolfram
- [Live-Stream: Exploring Pandemic Data][8] by Stephen & Christopher Wolfram + guests
- [Live-Stream: Exploring and Explaining Epidemic Modeling][9] by Stephen & Christopher Wolfram + guests
## ________________________________________
## [CALL for Making COVID-19 Data Computable (*link*)][14]
More pandemic-related information and data sets emerging every day. We invite people in the community to contribute to making more data surrounding this topic computable. Here is a call to action with some recommendations for people who want to do more, whether it's just pointing out relevant data sources, or taking the time to make some of that data computable and more instantly ready for other people to explore: https://wolfr.am/COVID-19-DATA .
## ________________________________________
## [Curated Computable Data (*link*)][15]
[FOLLOW THIS LINK][15] to see all available COVID-19 data repositories ready for computation in the Wolfram Language .
We have published and are continuously updating the Wolfram Data Repository entries. Below are a few key ones. Follow the link above to browse all repositories. We encourage you to make [*your own contributions*][16] of curated data relevant to COVID-19.
> **Pandemic Data for Novel Coronavirus COVID-19**
> https://www.wolframcloud.com/obj/resourcesystem/published/DataRepository/resources/Epidemic-Data-for-Novel-Coronavirus-COVID-19
> **Genetic Sequences for the SARS-CoV-2 Coronavirus**
> https://datarepository.wolframcloud.com/resources/Genetic-Sequences-for-the-SARS-CoV-2-Coronavirus
> **Patient Medical Data for Novel Coronavirus COVID-19**
> https://datarepository.wolframcloud.com/resources/Patient-Medical-Data-for-Novel-Coronavirus-COVID-19
> **COVID-19 Hospital Resource Use Projections**
> https://datarepository.wolframcloud.com/resources/COVID-19-Hospital-Resource-Use-Projections
> **OECD Data: Hospital Beds Per Country**
> https://datarepository.wolframcloud.com/resources/OECD-Data-Hospital-Beds-Per-Country
> **Hospital Beds Per US State**
> https://datarepository.wolframcloud.com/resources/Hospital-Beds-Per-US-State
## ________________________________________
## [Computational Publications (*link*)][17]
We encourage you to share your computational explorations relevant to coronavirus on Wolfram Community as stand-alone articles and then comment with their URL links on this discussion thread. We will summarize these articles in the following list:
### ________________________________
###FEATURED
> **COVID-19 Livestream Notebook March 24** by Stephen Wolfram
> https://www.wolframcloud.com/obj/s.wolfram/Published/COVID-19-Livestream-March-24.nb
> **Agent-Based Networks Models for COVID-19** by Christopher Wolfram
> https://community.wolfram.com/groups/-/m/t/1907703
> **Epidemiological Models for Influenza and COVID-19** by Robert Nachbar
> https://community.wolfram.com/groups/-/m/t/1896178
> **Epidemic simulation with a polygon container** by Francisco Rodríguez
> https://community.wolfram.com/groups/-/m/t/1901002
> **Distance to nearest confirmed US COVID-19 case** by Chip Hurst
> https://community.wolfram.com/groups/-/m/t/1911583
### ________________________________
### EPIDEMIC MODELING: SIMULATION
> **Epidemic simulation with a polygon container** by Francisco Rodríguez
> https://community.wolfram.com/groups/-/m/t/1901002
> **Agent based epidemic simulation** by Jon McLoone
> https://community.wolfram.com/groups/-/m/t/1900481
> **Modeling the spatial spread of infection diseases in the US** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/1889072
> **Geo-spatial-temporal COVID-19 simulations and visualizations over USA** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/1900514
### ________________________________
### EPIDEMIC MODELING: COMPARTMENTAL
> **Stochastic Epidemiology Models with Applications to the COVID-19** by Robert Nachbar
> https://community.wolfram.com/groups/-/m/t/1980051
> **COVID19: Italian SIRD estimates and prediction** by Christos Papahristodoulou
> https://community.wolfram.com/groups/-/m/t/1984320
> **Solver for COVID-19 epidemic model with the Caputo fractional derivatives** by Alexander Trounev
> https://community.wolfram.com/groups/-/m/t/1976589
> **Epidemiological Model for repetitive rapid testing for COVID-19** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/2075883
> **Phase transition of a SIR agent-based models** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/1977230
> **A simple estimate of covid-19 fatalities based on past data** by Kay Herbert
> https://community.wolfram.com/groups/-/m/t/1959438
> **SIR Model with Log-normal infected periods** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/1946292
> **SEI2HR-Econ model with quarantine and supplies scenarios** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1937880
> **COVID-19 - Policy Simulator - Can you find the perfect policy?** by Jan Brugard
> https://community.wolfram.com/groups/-/m/t/1931352
> **Epidemiological Models for Influenza and COVID-19** by Robert Nachbar
> https://community.wolfram.com/groups/-/m/t/1896178
> **Exploring Epidemiological Modeling** by Jordan Hasler
> https://community.wolfram.com/groups/-/m/t/1920119
> **SEI2HR model with quarantine scenarios** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1926505
> **The SIR Model for Spread of Disease** by Arnoud Buzing
> https://community.wolfram.com/groups/-/m/t/1903289
> **COVID-19 - R0 and Herd Immunity - are we getting closer?** by Jan Brugard
> https://community.wolfram.com/groups/-/m/t/1911422
> **Basic experiments workflow for simple epidemiological models** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1895675
> **Scaling of epidemiology models with multi-site compartments** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1897377
> **WirVsVirus 2020 hackathon participation** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1907256
> **An SEIR like model that fits the coronavirus infection data** by Enrique Garcia Moreno
> https://community.wolfram.com/groups/-/m/t/1888335
> **A SEIRD Model For COVID-19 Using DDEs** by Luis Borgonovo
> https://community.wolfram.com/groups/-/m/t/1996374
> **A Neat Package for Compartmental Model Diagrams** by Hamza Alsamraee
> https://community.wolfram.com/groups/-/m/t/2078640
### ________________________________
### EPIDEMIC MODELING: LOGISTIC
> **COVID-19 pandemic data in Italy** by Riccardo Fantoni
> https://community.wolfram.com/groups/-/m/t/1909687
> **Predicting Coronavirus Epidemic in United States** by Robert Rimmer
>https://community.wolfram.com/groups/-/m/t/1906954
> **Tracking Coronavirus Testing in the United States** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1902302
> **Logistic Model for Quarantine Controlled Epidemics** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1900530
> **Updated: coronavirus logistic growth model: China** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1890271
> **Coronavirus logistic growth model: China** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1887435
> **Coronavirus logistic growth model: Italy and South Korea** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1887823
> **Coronavirus logistic growth model: South Korea** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1894561
> **Logistic growth model for epidemic Covid-19 in Colombia** by Diego Ramos
> https://community.wolfram.com/groups/-/m/t/2092786
### ________________________________
### GENOMICS
> **Analyzing Nextstrain Data with WFR Newick Functions (COVID-19/SARS-CoV-2)** by John Cassel
> https://community.wolfram.com/groups/-/m/t/1958952
> **Estimating the number of times the SARS CoV-2 virus has replicated** by Carlos Munoz
> https://community.wolfram.com/groups/-/m/t/1943243
>**From sequenced SARS-CoV-2 genomes to a phylogenetic tree** by Daniel Lichtblau
>https://community.wolfram.com/groups/-/m/t/1961461
> **Genome analysis and the SARS-nCoV-2** by Daniel Lichtblau
> https://community.wolfram.com/groups/-/m/t/1874816
> **Visualizing Sequence Alignments from the COVID-19** by Jessica Shi
> https://community.wolfram.com/groups/-/m/t/1875352
> **A walk-through of the SARS-CoV-2 nucleotide Wolfram resource** by John Cassel
> https://community.wolfram.com/groups/-/m/t/1887456
> **Geometrical analysis of genome for COVID-19 vs SARS-like viruses** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1878824
> **Chaos Game For Clustering of Novel Coronavirus COVID-19** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1875994
### ________________________________
### DATA ANALYSIS
> **COVID-19 - The Swedish Experiment - Is it working?** by Jan Brugard
> https://community.wolfram.com/groups/-/m/t/1974412
> **A simple COVID-19 spread model** by Daniel Lichtblau
> https://community.wolfram.com/groups/-/m/t/1945196
> **COVID19: The performance of the Swedish strategy** by Christos Papahristodoulou
> https://community.wolfram.com/groups/-/m/t/1990972
> **Exploring social trends on Covid-19 pandemic using WikipediaData** by Jofre Espigule-Pons
> https://community.wolfram.com/groups/-/m/t/1931508
> **Google Mobility Data** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1946686
> **Understanding Aggregate COVID Curves** by Christopher Wolfram
> https://community.wolfram.com/groups/-/m/t/2068457
> **Apple mobility trends data visualization** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1942813
> **Computing COVID-19 Spread Rates in US Cities** by Daniel Lichtblau
> https://community.wolfram.com/groups/-/m/t/1930261
> **COVID-19 data and the Newcomb Benford Distribution** by Gustavo Delfino
> https://community.wolfram.com/groups/-/m/t/1913908
> **Short-time trends for COVID-19**, by Fabian Wenger
> https://community.wolfram.com/groups/-/m/t/1912710
> **What countries are hit hard by COVID19 outbreak?** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1904507
> **COVID19 in Iran: under-diagnosis issue** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1891140
> **Argentina: COVID-19 Data Analysis** by Tobias Canavesi
> https://community.wolfram.com/groups/-/m/t/1932910
> **Analysis of the Change in Phillips Curve After COVID-19 with Regression** by Seojin Yoon
> https://community.wolfram.com/groups/-/m/t/2055704
> **COVID wave alert: statistical analysis and visualization** by Antonio Neves
> https://community.wolfram.com/groups/-/m/t/2115658
> **Predicting COVID-19 using cough sounds classification** by Siria Sadeddin
> https://community.wolfram.com/groups/-/m/t/2166833
### ________________________________
### DATA VISUALIZATIONS
> **Top 20 COVID countries HeatMap by absolute death and death in ppm** by Rodrigo Murta
> https://community.wolfram.com/groups/-/m/t/2004800
> **US Counties COVID-19 confirmed cases by population density timelines** by Bob Sandheinrich
> https://community.wolfram.com/groups/-/m/t/1992898
> **3D Modeling of the SARS-CoV-2 Virus in the Wolfram Language** by Jeff Bryant
> https://community.wolfram.com/groups/-/m/t/1989540
> **California COVID19 Data** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/2132204
> **COVID-19 progress in Peru macro regions: coast vs mountain vs jungle** by Francisco Rodríguez
> https://community.wolfram.com/groups/-/m/t/1965079
> **COVID-19 reopening criterion: a simple visualization** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1962615
> **100 Days of COVID19 Over US Counties** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1956368
> **Population Density Map** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1955760
> **Google Mobility Data** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1946686
> **COVID19 Case-Fatality Ratio, Income, and Age: Simple Visualization** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1939045
> **Data Analysis of Coronavirus in Mexico** by Ivan Martinez
> https://community.wolfram.com/groups/-/m/t/1927657
> **Confirmed COVID-19 Cases in Catalonia** by Bernat Espigulé Pons
> https://community.wolfram.com/groups/-/m/t/1919468
> **Distance to nearest confirmed US COVID-19 case** by Chip Hurst
> https://community.wolfram.com/groups/-/m/t/1911583
> **COVID19 Confirmed Cases: US Counties** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1950980
> **COVID19 data visualization across US counties** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/2119049
> **Maps for Visualizing Covid-19's Effect** by Eric Mockensturm
> https://community.wolfram.com/groups/-/m/t/1934457
> **US Counties COVID-19 deaths plot** by Bob Sandheinrich
> https://community.wolfram.com/groups/-/m/t/1918332
> **Comparing the spread of COVID-19 between countries**, Jan Brugard
> https://community.wolfram.com/groups/-/m/t/1905992
> **NY Times COVID-19 data visualization** by Anton Antonov
> https://community.wolfram.com/groups/-/m/t/1911668
> **COVID-19 cases for each administrative division in Spain** by Bernat Espigulé Pons
> https://community.wolfram.com/groups/-/m/t/1910116
> **Propagation risk of COVID-19 by local contact in Spain (10 - 14 March)** by Bernat Espigulé Pons
> https://community.wolfram.com/groups/-/m/t/1898126
> **Visualizing the Pandemic Data COVID-19** by Martijn Froeling
> https://community.wolfram.com/groups/-/m/t/1899870
> **COVID-19 visualization of turning point** by Isao Maruyama
> https://community.wolfram.com/groups/-/m/t/1899911
> **Mapping "Live" COVID Data on a Globe** by Gabriel Lemieux
> https://community.wolfram.com/groups/-/m/t/1902102
> **Novel Coronavirus COVID-19 in Brazil** by Estevao Teixeira
> https://community.wolfram.com/groups/-/m/t/1905950
> **Mapping Novel Coronavirus COVID-19 Outbreak** by Jofre Espigule-Pons
> https://community.wolfram.com/groups/-/m/t/1868945
> **Ways to visualize COVID-19 simulation results?** by Kyle Keane
> https://community.wolfram.com/groups/-/m/t/1962739
> **General and COVID-19 deaths in Sweden** by Oscar Rodriguez
> https://community.wolfram.com/groups/-/m/t/2006377
> **COVID19 Tokyo per days of the week** Isao Maruyama
> https://community.wolfram.com/groups/-/m/t/2133807
### ________________________________
### DATA PROCESSING
> **Cov-Tell: Daily COVID-19 Updates with Alexa (made with Wolfram APIFunction)** by Jessica Shi
> https://community.wolfram.com/groups/-/m/t/1958307
> **Build a COVID-19 Chest X-Ray Image Uploader with Cloud & Data Drop** by Jofre Espigule-Pons
> https://community.wolfram.com/groups/-/m/t/1919770
> **Scraping OpenTable's "State of the Industry" page** by Aaron Enright
> https://community.wolfram.com/groups/-/m/t/1911043
> **City-level Search Tool for Coronavirus (COVID-19) Confirmed Cases** by David Lomiashvili
> https://community.wolfram.com/groups/-/m/t/1913247
> **Web Scraper: New York Times Coronavirus Data** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1894426
> **TraCOV: Personalized COVID-19 Risk Analysis Tool** by Jessica Shi
> https://community.wolfram.com/groups/-/m/t/1977700
> **Mobility changes data: transforming to Wolfram Language dataset** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/2160386
### ________________________________
### Masks
> **Effect of mandatory mask usage in COVID cases** by Diego Zviovich
> https://community.wolfram.com/groups/-/m/t/1919060
> **Face mask detection: classifying image data** by Siria Sadeddin
> https://community.wolfram.com/groups/-/m/t/2139499
## ________________________________________
## [Livestream Archives (*link*)][18]
- Stephen & Christopher Wolfram + guests [Exploring Pandemic Data][19]
- Stephen & Christopher Wolfram + guests [Exploring and Explaining Epidemic Modeling][20]
- Robert Nachbar - [Epidemiological Models for Influenza and COVID-19][21]
- Brian Wood - [COVID-19 Dashboard Visualizations][22]
- John Cassel - [Behind the Genetic Sequences for Novel Coronavirus SARS-CoV-2][23]
- Keiko Hirayama - [Patient Data Exploration for the Novel Coronavirus COVID-19][24]
- Keiko Hirayama - [Pandemic Data Exploration for the Novel Coronavirus COVID-19][25]
- Diego Zviovich - [Geo-spatial-temporal COVID-19 Simulations and Visualizations Over USA][26]
- Anton Antonov - [COVID19 Epidemic Modeling: Compartmental Models][27]
- Anton Antonov - [Scaling of Epidemiology Models with Multi-site Compartments][28]
- Anton Antonov - [Simple Economic Extension of Compartmental Epidemiological Models][29]
- Juan Klopper - [Coronavirus medical data analysis][30]
- Juan Klopper - [Coronavrirus epidemiological data analysis][31]
- Rory Foulger - [Coronavirus Data Exploration - Wolfram Livecoding with Students][32]
## ________________________________________
## Other useful resources
- Arnoud Buzing [GitHub][33] repository and [Notebook Gallery][34] for coronavirus
- [Modeling a Pandemic like Ebola with the Wolfram Language](https://blog.wolfram.com/2014/11/04/modeling-a-pandemic-like-ebola-with-the-wolfram-language)
- [Epidemics at Wolfram Demonstrations](https://demonstrations.wolfram.com/search.html?query=epidemic)
- [IGSIRProcess - IGraph Epidemic models][35]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1China_c.png&userId=1624544
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1.5US_c.png&userId=1624544
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2World_c.png&userId=1624544
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=3Genetic_c.png&userId=1624544
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=4Patient_c.png&userId=1624544
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5Resources_c.png&userId=1624544
[7]: https://www.wolframcloud.com/obj/examples/COVID19Preview.png
[8]: https://youtu.be/Vs5APySGYnk
[9]: https://youtu.be/kC6LHAv_lx0
[10]: https://www.wolframcloud.com/obj/s.wolfram/Published/COVID-19-Livestream-March-24.nb
[11]: https://community.wolfram.com/groups/-/m/t/1907703
[12]: https://community.wolfram.com/groups/-/m/t/1896178
[13]: https://community.wolfram.com/groups/-/m/t/1901002
[14]: https://community.wolfram.com/groups/-/m/t/1908923
[15]: https://datarepository.wolframcloud.com/search/?i=COVID-19
[16]: https://reference.wolfram.com/language/workflow/SubmitToTheWolframDataRepository.html
[17]: http://wolfr.am/StaffPicks
[18]: https://www.youtube.com/playlist?list=PLxn-kpJHbPx3_hUbroRYC_7NxcOwZ1SWa
[19]: https://youtu.be/Vs5APySGYnk
[20]: https://youtu.be/kC6LHAv_lx0
[21]: https://youtu.be/pcFB6_yrxGE
[22]: https://youtu.be/vUq8qx7kTYA
[23]: https://youtu.be/HCJgv3N_kDo
[24]: https://youtu.be/MlI_8o4A3BA
[25]: https://youtu.be/P86ZY-znE64
[26]: https://youtu.be/Kjk-sYlg-U0
[27]: https://youtu.be/LRs9rYCXIzs
[28]: https://youtu.be/b8oCNjRI0gY
[29]: https://youtu.be/C-sjXQiPE7s
[30]: https://youtu.be/gA0TPQZgNY0
[31]: https://youtu.be/I-n3zN4aU6c
[32]: https://youtu.be/4xCfPIiredM
[33]: https://github.com/arnoudbuzing/wolfram-coronavirus
[34]: https://wolfr.am/JZNRriEE
[35]: http://szhorvat.net/mathematica/IGDocumentation/#epidemic-modelsVitaliy Kaurov2020-02-04T15:18:14ZUS Counties COVID-19 confirmed cases by population density timelines
https://community.wolfram.com/groups/-/m/t/1992898
*MODERATOR NOTE: coronavirus resources & updates:* https://wolfr.am/coronavirus
----------
&[Wolfram Notebook][1]
[Original]: https://www.wolframcloud.com/obj/bobs/Published/COVID19-USCounty-PopulationDensityTimelines.nb
[1]: https://www.wolframcloud.com/obj/2a2e1af5-c751-41e5-abf1-1ad84f695f24Bob Sandheinrich2020-06-02T16:28:47ZBuild a 3D Self-Driving Car Simulation
https://community.wolfram.com/groups/-/m/t/2137315
## Introduction
In this article we will create a simple driving simulation to train a classifier to autonomously drive a virtual car. Our simulation will consist of a 3D scene composed of a windy road and a single car controller either by the user or the computer. The car will have a camera positioned in front of it to provide an image from its point of view (POV). This point of view image will be used as the input to our classifier to decide how to control the car. During each step of the simulation the car will be allowed to move forward or turn in place left or right.
![enter image description here][1]
## Building the Simulation
### Simulation Graphics
We will begin by creating the graphics functions to assemble and display the simulation. First lets create a texture for the ground. For simplicity we will rasterize a built-in curve containing both left and right turns for the road.
track = Rasterize[
With[{road =
HilbertCurve[2, DataRange -> {{0.25, 1.75}, {0.25, 1.75}}] /.
Line -> BSplineCurve},
Graphics[{
CapForm["Round"],
Gray, AbsoluteThickness[36], road,
Yellow, Dashing[0.033], AbsoluteThickness[2], road
},
PlotRange -> {{0, 2}, {0, 2}},
Background -> RGBColor["#e8e1ba"]
]
]
]
![enter image description here][2]
Next we will define a function to assemble the 3D scene encompassing the ground and car. We will be rendering this scene with two different cameras to provide an overview of the car on the road as well as the car's point of view image.
CarSimScene[sim_] := Module[{ground, car},
ground = {
Texture[track],
EdgeForm[None],
Polygon[
{{0, 0, 0}, {100, 0, 0}, {100, 100, 0}, {0, 100, 0}},
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
]
};
car =
With[{dimensions = {2, 1, 0}},
{Red,
Rotate[
Cuboid[sim["Position"] - dimensions ,
sim["Position"] + dimensions + {0, 0, 1}], sim["Rotation"],
{0, 0, 1},
sim["Position"]
]
}
];
{ground, car}
]
Lastly we need a function to position a camera in the 3D scene at the location of the car to record the point of view image. This image will only be used when classifying, so we rasterize at a relatively low resolution. After some experimentation I chose to use ImageResolution instead of RasterSize because it was over 2x faster to generate the final image. The ViewVector coordinates were determined experimentally to match the typical view from inside a car.
CarPOV[sim_] := Module[{
rotation = sim["Rotation"],
pos = sim["Position"]
},
Rasterize[
Graphics3D[
CarSimScene[sim],
ImageSize -> Small,
ViewVector -> {
sim["Position"] + {2.1 Cos[sim["Rotation"]],
2.1 Sin[sim["Rotation"]], 1.5},
sim["Position"] + {5 Cos[sim["Rotation"]],
5 Sin[sim["Rotation"]], -0.25}
},
ViewAngle -> 1.5,
Boxed -> False,
Background -> LightBlue,
ViewRange -> {0, 0.1}
],
ImageResolution -> 8
]
]
We can now put all of our graphics functions together into a single overarching function that displays the entire car simulation including the 3D scene and an inset from the car's point of view.
DisplayCarSim[sim_] := Module[{},
Overlay[{
Graphics3D[
CarSimScene[sim],
PlotRange -> {{0, 100}, {0, 100}, Automatic},
ImageSize -> Large,
Background -> LightBlue,
Boxed -> False
],
Labeled[
Framed[sim["POV"], FrameMargins -> None, FrameStyle -> Gray,
ImageSize -> Small], "Car POV", LabelStyle -> Gray]
}]
]
### Simulation Internals
With our simulation graphics complete we will proceed to building the functions that step the simulation forward. Our simulation state will be contained in a single association containing properties for the car's position, rotation, and current POV image, along with the history of all previous POV images and their associated actions.
NewCarSim initializes our data model for a new simulation. We allow a parameter to define which direction on the track the car starts from. We will generate training data in the "Forward" direction and then test the trained self-driving car in the opposite direction.
NewCarSim[direction_] := Module[{sim},
sim = If[
SymbolName[direction] == "Forward",
<|"Position" -> {10, 10, 0}, "Rotation" -> 0|>,
<|"Position" -> {90, 14, 0}, "Rotation" -> Pi|>
];
sim["History"] = {};
sim["POV"] = CarPOV[sim];
sim
]
Advancing the simulation is easy, StepCarSim takes a simulation state and action, one of "Up", "Left", or "Right", and moves the car accordingly. Every time the simulation is stepped forward the current car POV image is saved along with the provided action in our history list. At the end of a simulation step a new car POV image is generated.
StepCarSim[sim_, action_] := Module[{},
AppendTo[sim["History"], sim["POV"] -> action];
Switch[
action,
"Left", sim["Rotation"] += 0.05,
"Right", sim["Rotation"] -= 0.05,
"Up",
sim["Position"] += {Cos[sim["Rotation"]], Sin[sim["Rotation"]],
0}
];
sim["POV"] = CarPOV[sim];
sim
];
SetAttributes[StepCarSim, HoldFirst];
Our simulation is nearly complete, now it is time to build the interactive interface which allows a person to drive the car and generate training data.
## Generating Example Training Data
sim = NewCarSim[Forward];
EventHandler[
Style[Dynamic[DisplayCarSim[sim]], Selectable -> False],
{
"LeftArrowKeyDown" :> StepCarSim[sim, "Left"],
"RightArrowKeyDown" :> StepCarSim[sim, "Right"],
"UpArrowKeyDown" :> StepCarSim[sim, "Up"]
}
]
![enter image description here][3]
When I manually drove the car down the length of the entire track, the simulation generated nearly 600 training examples. This data is available in the Supplemental Materials section below if you would prefer not to create your own. Lets take a look at a few of the training examples:
TableForm@RandomSample[sim["History"], 3]
![enter image description here][4]
## Training the Self-Driving Car
Having generated our example data, we are now ready to train a classifier to drive the car!
selfDrivingCar =
Classify[sim["History"], Method -> "LogisticRegression"]
![enter image description here][5]
I chose to specify logistic regression because it provided the best accuracy for a relatively small evaluation time. We can show information about our classifier and see accuracy above 70%. By inspecting the learning curve and accuracy curve it looks like we are approaching a limit to our learning, but could probably still benefit from a few more training examples. Still, with our modest amount of example data, the autonomous car performs well.
Information[selfDrivingCar]
![enter image description here][6]
To preview our self-driving car we will step the simulation one hundred times using our new classifier to drive the car. This only gets us a little ways around the track, but shows the classifier is working.
DynamicModule[{selfDrivingSim = NewCarSim[Backward]},
Print[Dynamic[DisplayCarSim[selfDrivingSim]]];
Do[StepCarSim[selfDrivingSim, selfDrivingCar[selfDrivingSim["POV"]]],
100];
]
![enter image description here][7]
We could increase the number of steps to see the car drive to the end, but due to the relatively slow rendering performance I prefer to pre-render every 5th or 10th frame and assemble those in a Manipulate to easily pan back and forth through time:
selfDrivingSim = NewCarSim[Backward];
frames = Table[
With[{img = Rasterize[DisplayCarSim[selfDrivingSim]]},
Do[StepCarSim[selfDrivingSim,
selfDrivingCar[selfDrivingSim["POV"]]], 5];
img
],
120
];
Manipulate[frames[[t]], {t, 1, Length[frames] - 1, 1}]
![enter image description here][8]
So, how well does our self-driving car work? Quite well as a matter of fact. It can easily make it down the entire track, and stays on the right side of the road too! But what happens if we start the car on the wrong side of the road? Does it get confused? Let's see:
DynamicModule[{selfDrivingSim = NewCarSim[Backward]},
selfDrivingSim["Position"] -= {0, 4, 0};
Print[Dynamic[DisplayCarSim[selfDrivingSim]]];
Do[StepCarSim[selfDrivingSim, selfDrivingCar[selfDrivingSim["POV"]]],
100];
]
![enter image description here][9]
When starting on the wrong side of the road the self-driving car immediately corrects and steers back to the right side! Our car works wonderfully, especially considering the modest training set and limited manual optimization of Classify.
## Conclusion
In conclusion we can use Mathematica to create and render a 3D simulation while also interfacing with its machine learning tools to build a complete end to end experimental system. I hope this example provides some insight into the power of Mathematica's machine learning and graphics capabilities.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif-6-c4f303fe5f33.gif&userId=11733
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.19.25PM.png&userId=2137254
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.22.36PM.png&userId=2137254
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10103ScreenShot2020-12-13at2.23.23PM.png&userId=2137254
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=9171ScreenShot2020-12-13at2.24.29PM.png&userId=2137254
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5376ScreenShot2020-12-13at2.25.22PM.png&userId=2137254
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.26.30PM.png&userId=2137254
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-12-13at2.27.13PM.png&userId=2137254
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2628correcting-self-driving-car.gif&userId=2137254Dan Bridges2020-12-13T22:43:34ZDensely Connected Convolutional Networks: construction and application
https://community.wolfram.com/groups/-/m/t/2166844
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/738560fc-a66b-45b8-9a30-957d5b5068e1
[Original]: https://www.wolframcloud.com/obj/59f60d36-b055-41bd-9bd5-8d75a14df0c8
[Modified1]: https://www.wolframcloud.com/obj/b4fd2d06-4972-463b-9f83-2e03356b267aSiria Sadeddin2021-01-18T23:09:50ZSurprising Reflections from Cylinder to Cone
https://community.wolfram.com/groups/-/m/t/2167228
![enter image description here][1]
Recognize your favorite snack or beverage in the above pictures? No worry, it is a catoptric- or mirror anamorphosis. These are distorted images that can only be seen undeformed when reflected in a mirror from a prescribed point of view. This contribution will explain how the above and other images are made with the help of Mathematica.
To set up an anamorphic experiment, one needs 3 items: a (curved) mirror, a (deformed) anamorphic surface and a defined point of view.
For the setup here, the **mirror**, where we want the undeformed image reflected, is a chrome plated right cone, also used in a previous experiment "[Optical Illusions and Self-Anamorphism in a Conical Mirror][2]". The **anamorphic surface** , where the deformed image will be, is the wall of a plastic open top right cylinder arranged around the conical mirror. The **point of view** is at infinity on the central axis of both cone and cylinder (the z-axis).
![enter image description here][3]
Let us take a look at the geometry of the setup: (due to the radial symmetry we show only one half of a cross section) the triangle TAO is a cross section of the cone and the line DE is a cross section of the cylinder wall.
![enter image description here][4]
S is a point on the cylinder wall ED. A ray of light emitted by S is reflected by the mirror at Q and meets the eye at V. n is the normal on the cone surface at Q.The eye looks down from V and perceives the point as the point R reflected in the conical mirror. In other words: R is the reflection of S and S is the anamorphic map of R.
The cone has a base radius rk of 30mm and a height hk of 52mm which makes an opening angle of 60 degrees. The surrounding cylinder has a radius rc of 47.5mm.
With the Cartesian coordinates of a point R in the cone's base, the following function computes the coordinates of S in a development along the wall of the cylinder:
anaCone2Cylinder[{xr_, yr_}, rc_ : 47.5] /; xr^2 + yr^2 <= 1800 :=
Module[{rk = 30., \[Alpha] = 30 Degree, ri, ti, ra},
(*polar coordinates of R*){ri, ti} = {Sqrt[xr^2 + yr^2],
ArcTan[xr, yr]};(*ordinatee of the pointS*)
ra = -(rc - ri) Cot[2 \[Alpha]] + (rk - ri) Cot[\[Alpha]]; {rc ti,
ra}]
This shows both domain (left) and range {right) of the function anaCone2Cylinder as a 20 by 20 lines raster. The domain is the base of the cone and the range is the development of the cylinder wall.
![enter image description here][5]
We can now test this function on an image defined by a set of points. A first experiment is to use a club suit letter-form available in Mathematica and convert it to a set of points scaled to fit inside the base of the cone:
clubPts =
5 MeshCoordinates[
BoundaryDiscretizeGraphics[
Text[Style["\[ClubSuit]", Bold]], _Text,
MaxCellMeasure -> 0.1]];
Graphics[{Circle[{0, 0}, 30], AbsoluteThickness[3], Blue,
Line[clubPts]}, Axes -> True, AxesStyle -> Small]
![enter image description here][6]
After applying *anaCone2Cylinder* to the set of points, we get a development of its anamorphic map on the cylinder wall.
anaClbPts = anaCone2Cylinder[#] & /@ clubPts;
Graphics[{AbsoluteThickness[6], Blue,
Line[Select[Partition[anaClbPts, 2, 1],
EuclideanDistance @@ # < 10 &]]}, Axes -> True,
AxesStyle -> Small]
![enter image description here][7]
This is the result of printing the above and fitting it inside the cylinder. The anamorphic print on the cylinder wall reflects as the original (virtual ) image in the base of the conical mirror:
![enter image description here][8]
Circular logos are ideal material to use here since they can completely fill the base of the cone without any "overflow". The following two logos are used here and are in full resolution on the attached notebook "usedLogos.nb"
{wolf, cow} = usedLogos;
![enter image description here][9]
To apply our function anaCone2Cylinder, we need to convert the logo images to a radial set of colored polygons. The function [ImageRadialDivide][10] that I submitted to the Wolfram Function Repository is ideal for this. This is a partial magnification of the wolf logo that shows the radially aligned polygons:
Graphics[ResourceFunction["ImageRadialDivide"][
ImageReflect[wolf, Left]]]
![enter image description here][11]
We then use the same procedure as with the club suit image and get the following cylinder development:
wolfPolys =
ResourceFunction["ImageRadialDivide"][ImageReflect[wolf, Left]];
anaWolfPolys =
wolfPolys /. {x_?NumericQ, y_} -> anaCone2Cylinder[30 {x, y}];
Graphics[anaWolfPolys]
![enter image description here][12]
The result of fitting the printout of the development inside the cylinder and reflecting it in the central mirror:
![enter image description here][13]
The same procedure can be repeated for the "laughing cow" logo to get the following:
cowLogo = ImageReflect[ImageResize[cow, 400], Left];
cowPolys = ResourceFunction["ImageRadialDivide"][cowLogo];
anaCowPolys =
cowPolys /. {x_?NumericQ, y_} -> anaCone2Cylinder[30 {x, y}];
Graphics[anaCowPolys]
![enter image description here][14]
![enter image description here][15]
Finally, here are some more famous logos with their anamorphic deformation (right) and the corresponding reflection (left) in a conical mirror .
![enter image description here][16]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2161logosintroduo.png&userId=68637
[2]: https://community.wolfram.com/groups/-/m/t/2027565
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=completesetupsmall.png&userId=68637
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=6442geometry.png&userId=68637
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=rasteroverview.png&userId=68637
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=clubreflectionsmall.png&userId=68637
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=clubdevelopmentsmall.png&userId=68637
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=clubcombismall.png&userId=68637
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=usedlogossmall.png&userId=68637
[10]: https://resources.wolframcloud.com/FunctionRepository/resources/ImageRadialDivide
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1352wolfradial.png&userId=68637
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=wolfdevelopmentsmall.png&userId=68637
[13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=wolfcombismall.png&userId=68637
[14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=cowdevelopmentsmall.png&userId=68637
[15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=cowcombi.png&userId=68637
[16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=totaloverviewcopy.png&userId=68637Erik Mahieu2021-01-19T08:51:10ZStatistical age determination of tree rings
https://community.wolfram.com/groups/-/m/t/2167532
![enter image description here][1]
&[Wolfram Notebook][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Image20210119162952.jpg&userId=20103
[2]: https://www.wolframcloud.com/obj/wolfram-community/Published/tree_rings_3.nbMartin Ricker2021-01-19T13:30:37Z