struct

Shale::Matrix4(T)

Inherits Indexable::Mutable < Indexable < Enumerable < Iterable < Struct < Value < Object

Matrix4

Description

FIXES:

  • Figure out the best flow for the data setting and method operations
  • Not sure about the efficency of the value setting, like with #identity, then doing out of order changes to other indices, what if, at all, performance loss is there

Constants

POINTS = 16
SIDE = Math.isqrt(POINTS)

Constructors

Instance methods

*(other : Matrix4(T)) : self

Multipy matrices

Description

Source
[](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]?

Source
[]=(y : Int, x : Int, value : T) : T
Source
identity

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

Source
initialize
Source
inspect(io : IO) : Nil

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)"
Source
perspective(fov : Float32, aspect_ratio : Float32, z_near : Float32, z_far : Float32) : self

Perspective proc

Description

Source
pretty_print(pp : PrettyPrint) : Nil

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.

Source
rotation(x : Number, y : Number, z : Number) : self

Rotation proc

Description

Source
scale(x : T, y : T, z : T) : self

Scale proc

Description

Source
size

Returns the number of elements in this container.

Source
ss_transform(half_width : T, half_height : T) : self

Screen Space Transform proc

Description

Source
transform(other : Vector4) : Vector4

Transform matrix with a vector

Description

Source
translation(x : T, y : T, z : T) : self

Translation proc

Description

Source
unsafe_fetch(index : Int)

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.

Source
unsafe_put(index : Int, value : 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.

Source