Skip to content

v1.0.0

Choose a tag to compare

@thewizardplusplus thewizardplusplus released this 28 Jul 02:00
· 39 commits to master since this release

Major version. Add the Vector2D class.

Change Log

  • Add the Vector2D class

Features

  • Classes:
    • Vector2D:
      • Constants:
        • ZERO — (0, 0)
        • BASIS_X — (1, 0)
        • BASIS_Y — (0, 1)
      • Operations:
        • equals(other) — check exact equality
        • almost_equals(other, [epsilon]) — check approximate equality within a given epsilon
        • length_squared() — compute the squared length
        • length() — compute the length
        • normalized() — return the normalized vector
        • add(other) — add another vector
        • sub(other) — subtract another vector
        • mul(value) — multiply by a scalar or perform component-wise multiplication with another vector
        • neg() — unary minus
        • dot(other) — compute the dot product
        • div(value) — divide by a scalar or perform component-wise division by another vector
      • Operators (via metamethods):
        • == — check exact equality (__eq())
        • #vector — compute the length (__len()); supported only since Lua 5.2
        • + — add two vectors (__add())
        • - — subtract two vectors (__sub())
        • * — multiply by a scalar (vector * scalar or scalar * vector) or perform component-wise multiplication (vector * vector) (__mul())
        • -vector — unary minus (__unm())
        • / — divide by a scalar (vector / scalar) or perform component-wise division (vector / vector) (__div())