struct Geode::Point1(T)
- Geode::Point1(T)
- Geode::Point(T, 1)
- Struct
- Value
- Object
Overview
One dimensional point.
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/points/point1.crConstructors
-
.new(x : T)
Creates a point from its coordinates.
-
.new(&)
Constructs the point by yielding for each coordinate.
Class Method Summary
-
.[](x : T)
Constructs a point with existing coordinates.
-
.[](x)
Constructs a point with existing coordinates.
Instance Method Summary
-
#inspect(io : IO) : Nil
Produces a debugger-friendly string representation of the point.
-
#to_column : Matrix1x1(T)
Converts this point to a column vector, in other words a matrix with one column.
-
#to_row : Matrix1x1(T)
Converts this point to a row vector, in other words a matrix with one row.
-
#to_vector
Converts this point to a vector.
-
#tuple : Tuple(T)
Retrieves the coordinates as a tuple.
-
#x : T
Retrieves the x-coordinate.
Instance methods inherited from struct Geode::Point(T, 1)
==(other : Point)
==,
map(& : T -> U) : Point(U, N) forall U
map,
map_with_index(offset = 0, & : T, Int32 -> U) : Point(U, N) forall U
map_with_index,
near_zero?(tolerance)
near_zero?,
size
size,
to_s(io : IO) : Nil
to_s,
to_slice : Slice(T)
to_slice,
to_unsafe : Pointer(T)
to_unsafe,
to_vector
to_vector,
unsafe_fetch(index : Int)
unsafe_fetch,
zero?
zero?
Constructor methods inherited from struct Geode::Point(T, 1)
new(array : StaticArray(T, N))new(&) new, origin : self origin, zero : self zero
Constructor Detail
Constructs the point by yielding for each coordinate.
The value of each coordinate should be returned from the block. The block will be given the index of each coordinate as an argument.
Point1(Int32).new { |i| i + 5 } # => (5)
Class Method Detail
Constructs a point with existing coordinates.
The type of the coordinates is derived from the type of each argument.
Point1[1] # => (1)
Constructs a point with existing coordinates.
The type of the coordinates is specified by the type parameter. Each value is cast to the type T.
Point1F[1] # => (1.0)
Instance Method Detail
Converts this point to a column vector, in other words a matrix with one column.
point = Point1[5]
point.to_column # => [[5]]
Converts this point to a row vector, in other words a matrix with one row.
point = Point1[5]
point.to_row # => [[5]]