stdspansion/mathextras/vector2d

    Dark Mode
Search:
Group by:

Implements vector2ds, both floats and integers. Due to the way math works a lot of the time you will wind up with a float vector instead of an int vector. Converters are provided to help alleviate issues.

Types

FloatVector2D = object
  x*, y*: float
IntVector2D = object
  x*, y*: int

Funcs

func initFloatVector2d(x, y: SomeNumber): FloatVector2D {...}{.inline.}
func magnitude(self: FloatVector2D): float32 {...}{.inline, raises: [], tags: [].}
func normalize(self: FloatVector2D): FloatVector2D {...}{.inline, raises: [],
    tags: [].}
Normalize the vector
func initIntVector2d(x, y: SomeNumber): IntVector2D {...}{.inline.}
func add[T: SomeVector2D](a, b: T): T {...}{.inline.}
func sub[T: SomeVector2D](a, b: T): T {...}{.inline.}
func `div`[T: SomeVector2D](a, b: T): FloatVector2D {...}{.inline.}
func mul[T: SomeVector2D](a, b: T): T {...}{.inline.}
func `==`[T: SomeVector2D](a, b: T): bool {...}{.inline.}