ID:2860401
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Once we have a baked in /coord type, vectors are the logical next step for working with them.

This would necessitate overhauls to the following:

* movable.Move(vector2,Dir), to move to a location and face a specific direction (z is assumed to be preserved)

* bounds(vector2,z,w,h)

* bounds(vector2,vector2,z)

* movable.loc = vector2 shorthand, preserves z, uses absolute coordinate structure

* atom.vector2(anchor), where anchor is 0..15, SOUTHWEST = bottom left corner, NORTHEAST = top right corner, EAST|WEST, NORTH|WEST = center, returns new vector2 of specified bounds anchor point

* get_dir(vector2|atom,vector2|atom) // manhattan direction

* get_direction(vector2|atom,vector2|atom) //22.5 arc section direction

* get_dist(vector2|atom,vector2|atom) // manhattan distance (assume z)

* get_distance(vector2|atom,vector2|atom) // pythagorean distance (assume z)

* bounds_dist(ref,vector2|atom,w,h) //manhattan distance (assume z)

* bounds_distance(ref,vector2|atom,w,h) //pythagorean distance (assume z)

* get_angle(vector2|atom,vector2|atom) //arctan dx, dy shorthand (assume z)

* locate(vector2,z) //grab the turf at point on z level

* block(vector2,z,vector2,z) //grab the turf at point on z levels


Vector2s should have at least the following additional methods:

Magnitude()
Normalize()
Dot() //dot product
Cross() //cross product
Clamp(minx,maxx,miny,maxy) | Clamp(vector2 min,vector2 max)
Locate(z) // returns turf
Bounds(z,x,y,w,h) //similar to bounds() function
Step(dir,dist)
Step(ang,dist)
Step(vector2,dist)
coord(z) //return a /coord datum with the specified z coordinate

Similarly, integration with coords should be complete, allowing vector arithmetic on coords, but not vice versa. Where a z coordinate is not explicit, it should be inferred from the vector's other operand atom or coord.


See my megathread in Design Philosophy:

https://www.byond.com/forum/post/2860395