Vectors

Meshes.VecType
Vec(x₁, x₂, ..., xₙ)
Vec((x₁, x₂, ..., xₙ))
Vec{Dim,T}(x₁, x₂, ..., xₙ)
Vec{Dim,T}((x₁, x₂, ..., xₙ))

A geometric vector in Dim-dimensional space with coordinates of type T for linear algebra.

By default, integer coordinates are converted to float.

A vector can be obtained by subtracting two Point objects.

Examples

A = Point(0.0, 0.0)
B = Point(1.0, 0.0)
v = B - A

# 2D vectors
Vec(0.0, 1.0) # double precision as expected
Vec(0f0, 1f0) # single precision as expected
Vec(0, 0) # integer is converted to float by design
Vec2(0, 1) # explicitly ask for double precision
Vec2f(0, 1) # explicitly ask for single precision

# 3D vectors
Vec(1.0, 2.0, 3.0) # double precision as expected
Vec(1f0, 2f0, 3f0) # single precision as expected
Vec(1, 2, 3) # integer is converted to float by design
Vec3(1, 2, 3) # explicitly ask for double precision
Vec3f(1, 2, 3) # explicitly ask for single precision

Notes

  • A Vec is a subtype of StaticVector from StaticArrays.jl
  • Type aliases are Vec1, Vec2, Vec3, Vec1f, Vec2f, Vec3f
source
rand(Vec3, 100)
100-element Vector{Vec3}:
 Vec(0.1982099553258464, 0.15456061180040914, 0.3324926552341585)
 Vec(0.29529746650288846, 0.5412867916209496, 0.7488839496394143)
 Vec(0.9681324655722136, 0.16941169991435012, 0.9045509820158883)
 Vec(0.9801886080927941, 0.13165672577930154, 0.9894676362026733)
 Vec(0.23904578510991792, 0.5070676010005352, 0.39956307167831706)
 Vec(0.4829250619477039, 0.8273940050624361, 0.8606333186444342)
 Vec(0.6324759962678939, 0.42212903056979134, 0.8975332447260961)
 Vec(0.17539241472546563, 0.613015994468714, 0.8763544342470566)
 Vec(0.1450387331376063, 0.17904599397304255, 0.8874850779227733)
 Vec(0.0937604515129612, 0.37818998037107365, 0.7463856763003814)
 ⋮
 Vec(0.9306046028434176, 0.4994767785831272, 0.4629723236802856)
 Vec(0.9212036654897792, 0.9631624789444754, 0.6649874597193246)
 Vec(0.40080188664254046, 0.9142811309150185, 0.24670853667047088)
 Vec(0.23956532495127236, 0.11719133018065075, 0.528404679074511)
 Vec(0.5640141910004379, 0.20512349255296303, 0.08709976830704369)
 Vec(0.5197220057263477, 0.8941336485382126, 0.6449217373372845)
 Vec(0.45394924314155083, 0.9914279461387422, 0.48743193217253566)
 Vec(0.9823530285637736, 0.17784154833219834, 0.20158585354023295)
 Vec(0.061664448687017814, 0.37915888389202346, 0.581219975352335)