Skip to content
Richard Motorgeanu edited this page Mar 7, 2023 · 1 revision

Math Visualizer Library Documentation

This'll document everything for the internal usage of the library.
Most functionality will come from Messages being sent to the model, however there will be other helpful functions!

Hope this helps!
Richie

Functions

WIP
  • Adds a Vector2D to a grid.
  • Paramaters
    • Vector2D: The vector to add to the grid.
    • Int: The ID of the grid.

Messages

Individual Grid Manipulations

AddVector2D Vector2D Int
  • Adds a Vector2D to a grid.
  • Paramaters
    • Vector2D: The vector to add to the grid.
    • Int: The ID of the grid.
RemoveVector2D Int Int
  • Removes a Vector2D from a grid.
  • Paramaters
    • Int: The ID of the vector.
    • Int: The ID of the grid.
ScaleVector2D Float Int Int
  • Scales a Vector2D on a grid by a given value.
  • Paramaters
    • Float: The scalar value to scale the vector by.
    • Int: The ID of the vector.
    • Int: The ID of the grid.

Model Manipulations

AddGrid2D Grid2D
  • Adds the Grid2D.
  • Paramaters
    • Grid2D: The grid to add.
RemoveGrid2D Int
  • Removes the Grid2D with the given ID.
  • Paramaters
    • Int: The ID of the grid.

Data types

Coordinate2D

type alias Coordinate2D : (Float, Float)

defaultCoordinate2D = (0, 0)

Vector2D

type alias Vector2D : (Float, Float)

defaultVector2D = (0, 0)

Matrix2D

type alias Matrix2D : List Vector2D

defaultMatrix2D = [ (0, 0)
                  , (0, 0) ]

identityMatrix2D = [ (1, 0)
                   , (0, 1) ]

LineType

type LineType = Solid Float
            | Dotted Float
            | Dashed Float
            | Directional Float
            | Bidirectional Float

defaultLineType = Solid 1

Grid2D

type alias Grid2D = 
  { transformationMatrix : Matrix2D
  , vectorObjects : Dict Int Vector2D
  , xColor : Color
  , yColor : Color
  , xLineType : LineType
  , yLineType : LineType
  , scale : Float
  , offset : Coordinate2D
  }

defaultGrid2D =
  { transformationMatrix = defaultMatrix2D
  , vectorObjects = Dict.empty
  , xColor = black
  , yColor = black
  , xLineType = defaultLineType
  , yLineType = defaultLineType
  , scale = 5
  , offset = (0, 0)
  }