[List Jam 2021]
Lines, a list of ways you can use them, written by someone who failed Maths AS-level but who has since kind of learnt how to use them

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So the fundamentals:

1 Given two points, A & B, as an XY(Z) vector
2 You can draw a straight line between them,
- by doing B - A to get the vector from A to B
- you can also add A + B for a resulting position
3 With that line, you now have access to:
- The magnitude of the vector
- If you normalise it, the direction of that line
- The normal of the line: the right-angle of the direction
- Parallel lines (take the line, then add/subtract the normal)
- A point along the line:
- given a time t of 0 (at A) to 1 (at B)
- multiply the magnitude,
- and use the result with the direction

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So now we have a straight line, what to do with it?

- for movement:
- take a given point C, add a line AB to it: it's now somewhere else (whoa)
- use a vector to store how much "power" an engine outputs, using the magnitude to spin wheels with, or do X/Y to make it more interesting

- to calculate stuff:
- from an AI agent to something else, how far away is it?
- say X is a minimum value, and Y is a maximum: you now have a range, maybe  to randomly generate a value between
- if the player is looking at something

- for storing data:
- an index in a 2D or 3D grid
- a package of info for an item: X could be the colour, Y the shape
- a coordinate on a map

- to display something:
- a progress bar: from A to B using a time t, how close are you to a goal?
- use the direction of the line for a compass: say 0x 1y is north, 1x 0y east, etc

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Say we have _two_ lines, now what?

- if you normalise the two, you then get them as unit vectors, now:
- by multiplying the two (x * x, y *y), you get a resulting thingama-vector:
- this can be used for the Dot product, this gives you how aligned they are,
- and if you use the Cross product, how "up" & "down" the two result in
(...if the two are at right angles, that'll give you a big UP, if the two are matched/fully opposite, that's a big down)
(there's a whole bunch of math underneath that I don't know, that's the gist)

- check if they're intersecting:
- (how to do it can be pretty complicated, I always look it up or use a helper library)
- now with this you have the concept of whether something is "over" or "under another line,
- or, whether a point is inside/outside of an area (if say a line denotes a gate perhaps)
- this could be used for an AI sensor: if the point is beyond a line, then set a condition on/off

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now let's get fancy:

- Triangles:
- given 3 lines all connected to each other, you now have a triangle
- that triangle gives us A LOT of useful info:
- a polygon - an enclosed space that we can use for testing if something is inside or outside of
- a flat plane - a triangle (in most cases) can't intersect itself
- a facing - say that if you count the points clockwise, that's "up" or "out", with that we now the facing of a triangle to display something on
- if you have a load of triangles, then stitch them all together, you now have the components for a mesh of them.
This mesh can then be used with all their facings to do ~complex rendering stuff~ to then create 2D/3D objects with
- (this also relies on having another set of 2D points, that for each point on your triangle stores the UV position.
This is used for figuring out where on a 2D square - say, a texture - to place this triangle on)
(...it's called a UV, because W is an important maths symbol, and XYZ are already used for coordinates)

- A list of points: oh yeah, A, B, AND C, D, maybe ~even more~
- now you have a trail
- a path for something to walk along,
- or a path to compare against another path, like drawing a matching pattern
- or a line to avoid
- or a line with branches (A -> B -> C, B -> D, so on)
- or have all the points move, like a rolling wave,
- or have the first point move, then have each point after it move the same magnitude towards the one before
(so if A moves, then move B to A, C to B, D to C, etc.)

- _Curved_ lines:
- instead of just saying A to B, what if, for a given time t, the line was somewhere else?
- we can use equations to do this, like x*y, or x2 * y, or whatever contraption you can think up
- or, use another line/curve:
- say for a line A -> B that is flat on the ground going off in some direction
- and another line, C 0,0 -> D 1,1
- as you travel across A to B with time t, also travel across C to D,
- taking the resulting position on CD & using it as the height off the ground for AB
(you can use that idea for _tons_ of stuff, this is an example)

 Status Released Category Other Author BigHandInSky