struct Shale::Matrix4(T)
- Shale::Matrix4(T)
- Struct
- Value
- Object
Overview
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
Included Modules
- Indexable::Mutable(T)
Defined in:
shale/matrix.crConstant Summary
-
POINTS =
16
-
SIDE =
Math.isqrt(POINTS)
Constructors
Instance Method Summary
-
#*(other : Matrix4(T)) : self
Multipy matrices
-
#[](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]
- #[]=(y : Int, x : Int, value : T) : T
-
#identity : self
Identity will set @data points
- #initialize
-
#inspect(io : IO) : Nil
Appends this struct's name and instance variables names and values to the given IO.
-
#perspective(fov : Float32, aspect_ratio : Float32, z_near : Float32, z_far : Float32) : self
Perspective proc
-
#pretty_print(pp : PrettyPrint) : Nil
Pretty prints
self
into the given printer. -
#rotation(x : Number, y : Number, z : Number) : self
Rotation proc
-
#scale(x : T, y : T, z : T) : self
Scale proc
-
#size
Returns the number of elements in this container.
-
#ss_transform(half_width : T, half_height : T) : self
Screen Space Transform proc
-
#transform(other : Vector4) : Vector4
Transform matrix with a vector
-
#translation(x : T, y : T, z : T) : self
Translation proc
-
#unsafe_fetch(index : Int)
Returns the element at the given index, without doing any bounds check.
-
#unsafe_put(index : Int, value : T)
Sets the element at the given index to value, without doing any bounds check.
Constructor Detail
Instance Method Detail
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]?
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
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)"
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.
Returns the number of elements in this container.
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.
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.