struct Geode::Vector1(T)
- Geode::Vector1(T)
- Geode::VectorBase(T, 1)
- Struct
- Value
- Object
Overview
Vector containing one component.
Using this type generally doesn't make sense, but it is included to complete some rules and combinations.
T is the scalar type.
Defined in:
geode/vectors/vector1.crConstructors
-
.new(components : Tuple(T))
Creates a vector from its components.
-
.new(array : StaticArray(T, 1))
Constructs the vector with pre-existing values.
-
.new(other : CommonVector(T, 1))
Copies the contents of another vector.
-
.new(x : T)
Creates a vector from its components.
-
.new(&)
Constructs the vector by yielding for each component.
Class Method Summary
-
.[](x : T)
Constructs a vector with existing components.
-
.[](x)
Constructs a vector with existing components.
Instance Method Summary
-
#to_column : Matrix1x1(T)
Converts this vector to a column vector, in other words a matrix with one column.
-
#to_row : Matrix1x1(T)
Converts this vector to a row vector, in other words a matrix with one row.
-
#tuple : Tuple(T)
Retrieves the components as a tuple.
-
#x : T
Retrieves the x component.
Instance methods inherited from struct Geode::VectorBase(T, 1)
map(& : T -> U) : CommonVector forall U
map,
to_slice : Slice(T)
to_slice,
to_unsafe : Pointer(T)
to_unsafe,
unsafe_fetch(index : Int)
unsafe_fetch
Constructor methods inherited from struct Geode::VectorBase(T, 1)
new(array : StaticArray(T, N))new(other : CommonVector(T, M)) forall M
new(&) new, zero : self zero
Instance methods inherited from module Geode::CommonVector(T, 1)
inspect(io : IO) : Nil
inspect,
map(& : T -> U) : CommonVector forall U
map,
map_with_index(offset = 0, & : T, Int32 -> U) : CommonVector(U, N) forall U
map_with_index,
size
size,
to_s(io : IO) : Nil
to_s,
zip_map(other : CommonVector(U, N), & : T, U -> V) : CommonVector(V, N) forall U, V
zip_map
Instance methods inherited from module Geode::VectorOperations(1)
&*(scalar : Number) : CommonVector
&*,
&+(other : CommonVector(T, N)) : CommonVector forall T
&+,
&-(other : CommonVector(T, N)) : CommonVector forall T
&-,
*(scalar : Number) : CommonVector
*,
+(other : CommonVector(T, N)) : CommonVector forall T
+,
-(other : CommonVector(T, N)) : CommonVector forall T- : self -, /(scalar : Number) : CommonVector /, //(scalar : Number) : CommonVector //, abs : self abs, abs2 : self abs2, ceil : self ceil, clamp(min : CommonVector(T, N), max : CommonVector(T, N)) : CommonVector forall T
clamp(min, max) : CommonVector
clamp(range : Range(CommonVector(T, N), CommonVector(T, N))) : CommonVector forall T
clamp(range : Range) : CommonVector clamp, edge(edge : CommonVector(T, N)) : self forall T
edge(edge : T) : self forall T edge, floor : self floor, fraction : self fraction, lerp(other : CommonVector(T, N), t : Number) : CommonVector forall T lerp, round(mode : Number::RoundingMode = :ties_even) : self
round(digits : Number, base = 10, *, mode : Number::RoundingMode = :ties_even) : self round, scale(vector : CommonVector(T, N)) : CommonVector forall T
scale(amount : Number) : CommonVector scale, scale!(vector : CommonVector(T, N)) : CommonVector forall T
scale!(amount : Number) : CommonVector scale!, sign : self sign
Instance methods inherited from module Geode::VectorMatrices(T, 1)
&*(matrix : CommonMatrix(U, M, M)) : CommonVector forall U, M
&*,
*(matrix : CommonMatrix(U, M, M)) : CommonVector forall U, M
*,
to_column : CommonMatrix
to_column,
to_row : CommonMatrix
to_row
Instance methods inherited from module Geode::VectorGeometry(1)
angle(other : CommonVector(T, N)) : Number forall T
angle,
dot(other : CommonVector(T, N)) forall T
dot,
dot!(other : CommonVector(T, N)) forall T
dot!,
forward(surface : CommonVector(T, N)) : CommonVector forall T
forward,
length
length,
mag
mag,
mag2
mag2,
normalize : CommonVector
normalize,
project(other : CommonVector(T, N)) : CommonVector forall T
project,
reflect(surface : CommonVector(T, N)) : CommonVector forall T
reflect,
refract(surface : CommonVector(T, N), eta : Number) : CommonVector forall T
refract,
scale_to(length : Number) : CommonVector
scale_to
Instance methods inherited from module Geode::VectorComparison(1)
==(other : CommonVector(T, N)) forall T
==,
compare(other : CommonVector(T, N)) : CommonVector(Int32, N) forall T
compare,
eq?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
eq?,
ge?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
ge?,
gt?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
gt?,
le?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
le?,
lt?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
lt?,
near_zero?(tolerance)
near_zero?,
zero?
zero?
Constructor Detail
Constructs the vector by yielding for each component.
The value of each component should be returned from the block. The block will be given the index of each component as an argument.
Vector1(Int32).new { |i| i + 5 } # => (5)
Class Method Detail
Constructs a vector with existing components.
The type of the components is derived from the type of each argument.
Vector1[1] # => (1)
Constructs a vector with existing components.
The type of the components is specified by the type parameter. Each value is cast to the type T.
Vector1F[1] # => (1.0)
Instance Method Detail
Converts this vector to a column vector, in other words a matrix with one column.
vector = Vector1[5]
vector.to_column # => [[5]]
Converts this vector to a row vector, in other words a matrix with one row.
vector = Vector1[5]
vector.to_row # => [[5]]