Behavioral Location Math: Difference between revisions

From Desynced Wiki
No edit summary
No edit summary
Line 1: Line 1:
[[Behavioral Primer]]
== Location Data Type Composition ==
== Location Data Type Composition ==



Revision as of 03:33, 4 September 2023

Behavioral Primer

Location Data Type Composition

As with other (link) Data Types the location data type is a composite of itself and a number component you can test this your self by manual assigning an input a location value under the world tab and using the number slider or input box at the bottom to set a number value after clicking the check box to enter the data if you hover over the input box you just modified you will see a col um of number 3 high like below.

1
6
9

This would be the x, y and number parts of the data type. However in most cases the number component will not do anything useful if you are trying to work with a location.

Relative Location Meaning on the World

As a X location value increases in value the location moves to the right by one grid unit. Decreases move the location to the left.

As a Y location value increases in value the location moves down by one grid unit. Decreases move the location Up.

Location Math

To do math on location data and get usable location results both inputs need to be location data. Math functions work as you would think but only applying the math function from X to X and Y to Y in location data.

Locations as a X, Y Plane

All the Locations possible on the world map combine to the equivalent to a X,Y plane in math with certain locations equivalent to the origin and X and Y axes on a plane.

Red: The Origin
Green & Red: The X axis
Yellow & Red: The Y axis

Special Property: Reflection

The most useful aspect of math on locations is multiplication in that it allows you to manipulate x,y values in relation to the axes of the x,y plane.

Reflection is easy to understand if you think of the axes as mirrors. If you wanted to see where the location reflection is across that mirror you would multiply by -1 to the opposite term for X 1,-1 for Y -1,1 and for both (across the Origin) by -1,-1

X and Y reflections by themselves are easy to visualize doing both can be harder to visualize but if you draw a line from the location through the Origin (0,0) and go past the Origin for the same length traveled to it, you will arrive at the correct location. A simpler bu two step process is to reflect One axis then using that result reflect the other.

Reflecting Outside of the Axes and Origin

Multiplication alone will limit how useful reflection can be as you can only reflect across the Axes in the world with it alone.

You can however reflect location data you are going to use for addition on any location and you can then get the reflections around any point in the world.

For example if you wanted to build four buildings in a square with a set location in the center you could hard code four separate sets of location data or choose one and reflect it 3 times to get the other corners then add all 4 values to the unit/location you want set to the center giving you a square of locations around any location you choose.

Here is an example program doing this:

DSCJZ2gFsiG0tMgkl2R0T0q2og9lI1E9VBB1uV7Hz1BwoZv42XrCz1VlimS1KWMNn2sdC4700X1VQ1pne7T1dRPGc31BuDR2pSPpk3mJKce2kZDc90Gc4Gb1JDH0t11dtIj0bjcaO2GwABA141CaR1Ovx6R0q6zey4Id5KV1SwcSR22V1zd2npAmY2CZcTq0Llza93ettl84GqCKy3JiIJm1AKfbO0U6Qt61lgGkY2y9pnB3TAhJr0YqNSX3eiGhp1p1a5g1YIVFb01hD9h4GSMeO2U8qRd0XjYSu1aonUZ2SK7d12oyTIW4HzyXK0yWCkI3JvEB93vD6d00df33J43ALxM4HRMQS3KPge43a4LfN2HJpRa4GlWkc2zcoDi4LNHU72chgXJ1omFqW3Z9YDr3wCUVF34pmBh25HsPh4OpYls3a4HDp0vH73K0TkTI03DHG8Q0qae8012eLdZ2uZdLW0opS0p0ZEsCA4HVzRt2zvCPb2Y4eKL0Lb9fV0pvC80