Skip to content

Instantly share code, notes, and snippets.

@johnlpage
Last active March 8, 2022 13:24
Show Gist options
  • Save johnlpage/840ab52504601166a73236273ee3637d to your computer and use it in GitHub Desktop.
Save johnlpage/840ab52504601166a73236273ee3637d to your computer and use it in GitHub Desktop.
[
{$limit:1},
{$set: { x : {$range:[-144,0]}, y : {$range:[-120,0]} }},
{$unwind :"$x"},
{$unwind: "$y"},
{$set : { r: {$add: [{$divide:["$x",8000]},-0.73]}, i: {$add:[{$divide:["$y",8000]},0.15]}}},
{$set : { c : { $reduce : { input: {$range:[0,300]}, initialValue : { r:0,i:0,it:0 }, in :
{ $cond : { if: { $lt:["$$value.r",4]}, then: { it:{$add:["$$value.it",1]},
r: {$add:[{$subtract:[{$pow:["$$value.r",2]}, {$pow:["$$value.i",2]} ]},"$r"]},
i: {$add: [{$multiply:[2,"$$value.r","$$value.i"]},"$i"]} } ,else: "$$value"}}}}}},
{$project: { x:1,y:1,intensity:"$c.it"}}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment