struct Geode::Point3(T)

Overview

Three dimensional point.

T is the scalar type.

Defined in:

geode/points/point3.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from struct Geode::Point(T, 3)

==(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, 3)

new(array : StaticArray(T, N))
new(&)
new
, origin : self origin, zero : self zero

Constructor Detail

def self.new(x : T, y : T, z : T) #

Creates a point from its coordinates.


[View source]
def self.new(&) #

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.

Point3(Int32).new { |i| i + 5 } # => (5, 6, 7)

[View source]

Class Method Detail

def self.[](x : T, y : T, z : T) #

Constructs a point with existing coordinates.

The type of the coordinates is derived from the type of each argument.

Point3[1, 2, 3] # => (1, 2, 3)

[View source]
def self.[](x, y, z) #

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.

Point3F[1, 2, 3] # => (1.0, 2.0, 3.0)

[View source]

Instance Method Detail

def inspect(io : IO) : Nil #

Produces a debugger-friendly string representation of the point.


[View source]
def to_column : Matrix3x1(T) #

Converts this point to a column vector, in other words a matrix with one column.

point = Point3[5, 7, 9]
point.to_column # => [[5], [7], [9]]

[View source]
def to_row : Matrix1x3(T) #

Converts this point to a row vector, in other words a matrix with one row.

point = Point3[5, 7, 9]
point.to_row # => [[5, 7, 9]]

[View source]
def to_vector #

Converts this point to a vector.

point = Point3[5, 7, 9]
point.to_vector # => (5, 7, 9)

[View source]
def tuple : Tuple(T, T, T) #

Retrieves the coordinates as a tuple.


[View source]
def x : T #

Retrieves the x-coordinate.


[View source]
def y : T #

Retrieves the y-coordinate.


[View source]
def z : T #

Retrieves the z-coordinate.


[View source]