struct Shale::Matrix4(T)

Overview

Matrix4

Description

FIXES:

Included Modules

Defined in:

shale/matrix.cr

Constant Summary

POINTS = 16
SIDE = Math.isqrt(POINTS)

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def *(other : Matrix4(T)) : self #

Multipy matrices

Description


[View source]
def [](y : Int, x : Int) : T #

Reason for flipping [x, y] is to match what is conventionally written in something like C where a multidim array would be equalivant matrix[y][x]

Not sure to have it like you would if writting on paper (x, y), maybe with symbols [x: 0, y: 0]?


[View source]
def []=(y : Int, x : Int, value : T) : T #

[View source]
def identity : self #

Identity will set @data points

Description

The matrix is setup as such: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1


[View source]
def initialize #

[View source]
def inspect(io : IO) : Nil #
Description copied from struct Struct

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"

[View source]
def perspective(fov : Float32, aspect_ratio : Float32, z_near : Float32, z_far : Float32) : self #

Perspective proc

Description


[View source]
def pretty_print(pp : PrettyPrint) : Nil #
Description copied from class Object

Pretty prints self into the given printer.

By default appends a text that is the result of invoking #inspect on self. Subclasses should override for custom pretty printing.


[View source]
def rotation(x : Number, y : Number, z : Number) : self #

Rotation proc

Description


[View source]
def scale(x : T, y : T, z : T) : self #

Scale proc

Description


[View source]
def size #
Description copied from module Indexable(T)

Returns the number of elements in this container.


[View source]
def ss_transform(half_width : T, half_height : T) : self #

Screen Space Transform proc

Description


[View source]
def transform(other : Vector4) : Vector4 #

Transform matrix with a vector

Description


[View source]
def translation(x : T, y : T, z : T) : self #

Translation proc

Description


[View source]
def unsafe_fetch(index : Int) #
Description copied from module Indexable(T)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.


[View source]
def unsafe_put(index : Int, value : T) #
Description copied from module Indexable::Mutable(T)

Sets the element at the given index to value, without doing any bounds check.

Indexable::Mutable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they modify elements with #[]=(index, value).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.


[View source]