Request for advice - mathematical operations

Request for advice - mathematical operations

I want to know if there are any plugins, widgets or macros that allow me to make this calculation.

I have the tiddler which has the ‘point’ field which contains latitude and longitude.

I want to get 4 points by increasing and decreasing latitude and longitude to create a square around the point.

I define the increment in value in an ‘inc’ variable.
if inc is “0.5” and point is “45.00,8.00”

I want:
p1 = 44.50,7.50
p2 = 44.50.8.50
p3 = 45.50.7.50
p4 = 45.50.8.50

and in a second step I will filter for all my tiddlers that have pont inside this square.

Now I’m stuck in the first part, getting the four points.

With this I split latidudine longitudine, but if I use the Mathematics Operators sum or subtract I sum / subtract latidudine and longitudine. Not what I want

<$ vars inc = “0.5”>

<$ list filter = “[all [current] get [point] split [,] trim [] fixed [4]] sum []” variable = center>

center + inc
center - inc

</ $ list>
</ $ vars>

I’ve found the “http://mathcell.tiddlyspot.com/” and the $ calc widget, but are there better ways to do this?

Thanks

There is reverse polish notation

https://tid.li/tw5/hacks.html#rpn%20–%20Basic%20Math%20in%20Reverse%20Polish%20Notation

And Evans formula plugin

https://chronicles.wiki/TiddlyWikiFormula/

2 Likes

G’day,

Download attached json and drag into TiddlyWiki.com to see if this is what you’re looking for.

Cheers !

PointsInRange.json (1.8 KB)

EDIT: Screenshot of my test results with tiddlers not in the attached JSON:

<$vars inc="0.5">
<$let  
  pt="45.00,8.00"
  laStart = {{{[<pt>split[,]nth[1]trim[]subtract<inc>fixed[4]]}}}
  loStart = {{{[<pt>split[,]nth[2]subtract<inc>fixed[4]]}}}
>
<$list filter="[range[1,2]]" variable="laFactor">
<$list filter="[range[1,2]]" variable="loFactor">
<$vars spinner={{{ [<laFactor>subtract[1]multiply[2]add<loFactor>] }}} >
<$text text={{{[<laFactor>subtract[1]multiply<inc>add<laStart>fixed[4]] [<loFactor>subtract[1]multiply<inc>add<loStart>fixed[4]]+[join[,]addprefix[=]addprefix<spinner>addprefix[p]]}}} /> <br/>
</$vars>
</$list>
</$list>
</$let>
</$vars>
2 Likes

I think the variable should be named delta instead of inc. … Just some minor details

1 Like

Using TWCore standard filters:

<$let inc="0.5"
    point={{{ [<currentTiddler>get[point]]  }}}
      lat={{{ [<point>split[,]nth[1]]       }}}
     long={{{ [<point>split[,]nth[2]]       }}}
      top={{{ [<lat>subtract<inc>fixed[2]]  }}}
      bot={{{ [<lat>add<inc>fixed[2]]       }}}
     left={{{ [<long>subtract<inc>fixed[2]] }}}
    right={{{ [<long>add<inc>fixed[2]]      }}}
       p1={{{ [<top>] [<left>]  +[join[,]]  }}}
       p2={{{ [<top>] [<right>] +[join[,]]  }}}
       p3={{{ [<bot>] [<left>]  +[join[,]]  }}}
       p4={{{ [<bot>] [<right>] +[join[,]]  }}}>

|    INCREMENT (inc)|   <<inc>>|
|     CENTER (point)| <<point>>|
|      TOP LEFT (p1)|    <<p1>>|
|     TOP RIGHT (p2)|    <<p2>>|
|   BOTTOM LEFT (p3)|    <<p3>>|
|  BOTTOM RIGHT (p4)|    <<p4>>|

</$let>

enjoy,
-e

3 Likes

A lot of information! Thank You

And a lot of tme to think about.

(Related to the old riddle: Where can you walk one km south, one km east and one km north and be in the same spot that you started?)

An extra consideration to think about for your application is that lines of longitude are not parallel. So your “square” will look more and more like a skinny triangle near the poles until it breaks down completely within one delta/inc. of the poles.

Projecting a “square” of equal area anywhere on the globe given a lat/long coordinate as input is possible but not trivial.

A simple approximation is given here but still won’t work at the poles:

The more rigorous solution is here:

… and even more equations to use here:
http://www.movable-type.co.uk/scripts/latlong.html

/Mike

1 Like

Just an aside for those interested in geolocation check out what3words.com which I think is a good match with tiddlywiki.

1 Like