Class: Numerix::Matrix3x2

Inherits:
MatrixBase show all
Defined in:
lib/numerix/matrix3x2.rb

Overview

A structure encapsulating a 3x2 matrix.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Structure

#address, #dup, #each, #pack, #ptr, size, unpack

Constructor Details

#initializeMatrix3x2 #initialize(m11, m12, m21, m22, m31, m32) ⇒ Matrix3x2

Returns a new instance of Matrix3x2.

Overloads:

  • #initializeMatrix3x2

    Creates a new matrix with all values set to 0.0.

  • #initialize(m11, m12, m21, m22, m31, m32) ⇒ Matrix3x2

    Constructs a Matrix3x2 from the given components.

    Parameters:

    • m11 (Float)

      The first element of the first row.

    • m12 (Float)

      The second element of the first row.

    • m21 (Float)

      The first element of the second row.

    • m22 (Float)

      The second element of the second row.

    • m31 (Float)

      The first element of the third row.

    • m32 (Float)

      The second element of the third row.

See Also:



54
55
# File 'lib/numerix/matrix3x2.rb', line 54

def initialize(*args)
end

Instance Attribute Details

#m11Float

Returns the first element of the first row.

Returns:

  • (Float)

    the first element of the first row.



9
10
11
# File 'lib/numerix/matrix3x2.rb', line 9

def m11
  @m11
end

#m12Float

Returns the second element of the first row.

Returns:

  • (Float)

    the second element of the first row.



13
14
15
# File 'lib/numerix/matrix3x2.rb', line 13

def m12
  @m12
end

#m21Float

Returns the first element of the second row.

Returns:

  • (Float)

    the first element of the second row.



17
18
19
# File 'lib/numerix/matrix3x2.rb', line 17

def m21
  @m21
end

#m22Float

Returns the second element of the second row.

Returns:

  • (Float)

    the second element of the second row.



21
22
23
# File 'lib/numerix/matrix3x2.rb', line 21

def m22
  @m22
end

#m31Float

Returns the first element of the third row.

Returns:

  • (Float)

    the first element of the third row.



25
26
27
# File 'lib/numerix/matrix3x2.rb', line 25

def m31
  @m31
end

#m32Float

Returns the second element of the third row.

Returns:

  • (Float)

    the second element of the third row.



29
30
31
# File 'lib/numerix/matrix3x2.rb', line 29

def m32
  @m32
end

#translationVector2

Returns the translation component of this matrix.

Returns:

  • (Vector2)

    the translation component of this matrix.



33
34
35
# File 'lib/numerix/matrix3x2.rb', line 33

def translation
  @translation
end

Class Method Details

.create_rotation(radians) ⇒ Matrix3x2 .create_rotation(radians, center) ⇒ Matrix3x2

Creates a rotation matrix.

Overloads:

  • .create_rotation(radians) ⇒ Matrix3x2

    Creates a rotation matrix using the given rotation in radians.

    Parameters:

    • radians (Float)

      The amount of rotation, in radians.

  • .create_rotation(radians, center) ⇒ Matrix3x2

    Creates a rotation matrix using the given rotation in radians and a center point.

    Parameters:

    • radians (Float)

      The amount of rotation, in radians.

    • center (Vector2)

      The center point

Returns:



403
404
# File 'lib/numerix/matrix3x2.rb', line 403

def create_rotation
end

.create_scale(x, y) ⇒ Matrix3x2 .create_scale(x, y, center) ⇒ Matrix3x2 .create_scale(scales) ⇒ Matrix3x2 .create_scale(scales, center) ⇒ Matrix3x2 .create_scale(scale) ⇒ Matrix3x2 .create_scale(scale, center) ⇒ Matrix3x2

Creates a scale matrix.

Overloads:

  • .create_scale(x, y) ⇒ Matrix3x2

    Creates a scale matrix from the given X and Y components.

    Parameters:

    • x (Float)

      Value to scale by on the X-axis.

    • y (Float)

      Value to scale by on the Y-axis.

  • .create_scale(x, y, center) ⇒ Matrix3x2

    Creates a scale matrix that is offset by a given center point.

    Parameters:

    • x (Float)

      Value to scale by on the X-axis.

    • y (Float)

      Value to scale by on the Y-axis.

    • center (Vector2)

      The center point.

  • .create_scale(scales) ⇒ Matrix3x2

    Creates a scale matrix from the given vector scale.

    Parameters:

    • scales (Vector2)

      The scale to use.

  • .create_scale(scales, center) ⇒ Matrix3x2

    Creates a scale matrix from the given vector scale with an offset from the given center point.

    Parameters:

    • scales (Vector2)

      The scale to use.

    • center (Vector2)

      The center point.

  • .create_scale(scale) ⇒ Matrix3x2

    Creates a scale matrix that scales uniformly with the given scale.

    Parameters:

    • scale (Float)

      The uniform scale to use.

  • .create_scale(scale, center) ⇒ Matrix3x2

    Creates a scale matrix that scales uniformly with the given scale with an offset from the given center.

    Parameters:

    • scale (Float)

      The uniform scale to use.

    • center (Vector2)

      The center point.

Returns:



363
364
# File 'lib/numerix/matrix3x2.rb', line 363

def create_scale(*args)
end

.create_skew(x, y) ⇒ Matrix3x2 .create_skew(x, y, center) ⇒ Matrix3x2

Creates a skew matrix.

Overloads:

  • .create_skew(x, y) ⇒ Matrix3x2

    Creates a skew matrix from the given angles in radians.

    Parameters:

    • x (Float)

      The X angle, in radians

    • y (Float)

      The Y angle, in radians

  • .create_skew(x, y, center) ⇒ Matrix3x2

    Creates a skew matrix from the given angles in radians and a center point.

    Parameters:

    • x (Float)

      The X angle, in radians

    • y (Float)

      The Y angle, in radians

    • center (Vector2)

      The center point.

Returns:



384
385
# File 'lib/numerix/matrix3x2.rb', line 384

def create_skew(*args)
end

.create_translation(position) ⇒ Matrix3x2 .create_translation(x, y) ⇒ Matrix3x2

Creates a translation matrix.

Overloads:

  • .create_translation(position) ⇒ Matrix3x2

    Creates a translation matrix from the given vector.

    Parameters:

    • position (Vector)

      The translation position.

  • .create_translation(x, y) ⇒ Matrix3x2

    Creates a translation matrix from the given X and Y components.

    Parameters:

    • x (Float)

      The X position.

    • y (Float)

      The Y position.

Returns:



319
320
# File 'lib/numerix/matrix3x2.rb', line 319

def create_translation(other)
end

.identityMatrix3x2

Returns the multiplicative identity matrix.

Returns:

  • (Matrix3x2)

    the multiplicative identity matrix.



301
302
# File 'lib/numerix/matrix3x2.rb', line 301

def identity
end

.lerp(matrix1, matrix2, amount) ⇒ Matrix3x2

Linearly interpolates from matrix1 to matrix2, based on the third parameter.

Parameters:

  • matrix1 (Matrix3x2)

    The first source matrix.

  • matrix2 (Matrix3x2)

    The second source matrix.

  • amount (Float)

    The relative weighting of matrix2, clamped between 0.0 and 1.0.

Returns:



416
417
# File 'lib/numerix/matrix3x2.rb', line 416

def lerp(matrix1, matrix2, amount)
end

Instance Method Details

#*(scalar) ⇒ Matrix3x2 #*(other) ⇒ Matrix3x2

Multiplies this matrix by the specified value.

Overloads:

  • #*(scalar) ⇒ Matrix3x2

    Scales all elements in a matrix by the given scalar factor.

    Parameters:

    • scalar (Float)

      The scaling value to use.

  • #*(other) ⇒ Matrix3x2

    Multiplies two matrices together and returns the resulting matrix.

    Parameters:

    • other (Matrix3x2)

      The source matrix to multiply.

Returns:



263
264
# File 'lib/numerix/matrix3x2.rb', line 263

def *(other)
end

#**(exponent) ⇒ Matrix3x2

Raises the matrix to the given power.

Parameters:

  • exponent (Float)

    The power to raise the matrix to.

Returns:

  • (Matrix3x2)

    New matrix that is result of the operation.



98
99
# File 'lib/numerix/matrix3x2.rb', line 98

def **(exponent)
end

#+(other) ⇒ Matrix3x2

Adds each matrix element in value1 with its corresponding element in the specified matrix.

Parameters:

Returns:

  • (Matrix3x2)

    A matrix containing the summed values.



235
236
# File 'lib/numerix/matrix3x2.rb', line 235

def +(other)
end

#-(other) ⇒ Matrix3x2

Subtracts each matrix element in the specified matrix from its corresponding element in this matrix to form a new matrix of the difference.

Parameters:

  • other (Matrix3x2)

    The matrix to subtract.

Returns:

  • (Matrix3x2)

    The matrix containing the resulting values.



246
247
# File 'lib/numerix/matrix3x2.rb', line 246

def -(other)
end

#-@Matrix3x2

Negates the given matrix by multiplying all values by -1.0.

Returns:



225
226
# File 'lib/numerix/matrix3x2.rb', line 225

def -@
end

#==(other) ⇒ Boolean

Returns flag if this matrix instance is equal to the given object.

Parameters:

  • other (Object)

    The object to compare.

Returns:

  • (Boolean)

    true if objects are equal, otherwise false.



272
273
# File 'lib/numerix/matrix3x2.rb', line 272

def ==(other)
end

#[](row, column) ⇒ Float?

Accesses the matrix component using the zero-based row/column indices.

Parameters:

  • row (Integer)

    The zero-based row index.

  • column (Integer)

    The zero-based column index.

Returns:

  • (Float, nil)

    the value at the specified location, or nil if an index is out of range.



283
284
# File 'lib/numerix/matrix3x2.rb', line 283

def [](row, column)
end

#[]=(row, column, value) ⇒ Float

Sets the matrix component using the zero-based row/column indices.

Parameters:

  • row (Integer)

    The zero-based row index.

  • column (Integer)

    The zero-based column index.

  • value (Float)

    The value to set.

Returns:

  • (Float)

    the value.



294
295
# File 'lib/numerix/matrix3x2.rb', line 294

def []=(row, column, value)
end

#column(index) ⇒ Array<Float>?

Returns the specified matrix column as an array.

Parameters:

  • index (Integer)

    The column index to retrieve.

Returns:

  • (Array<Float>, nil)

    the requested column, or nil if index is out of range.

See Also:



138
139
# File 'lib/numerix/matrix3x2.rb', line 138

def column(index)
end

#determinantFloat

Calculates the determinant for this matrix.

The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1).

Returns:

  • (Float)

    the determinant.



114
115
# File 'lib/numerix/matrix3x2.rb', line 114

def determinant
end

#each_column {|column| ... } ⇒ self

Enumerates the columns of the matrix.

Yields:

  • (column)

    Yields a column to the block.

Yield Parameters:

  • column (Array<Float>)

    The current column as an array.

Returns:

  • (self)

See Also:



162
163
# File 'lib/numerix/matrix3x2.rb', line 162

def each_column
end

#each_row {|row| ... } ⇒ self

Enumerates the rows of the matrix.

see each_column

Yields:

  • (row)

    Yields a row to the block.

Yield Parameters:

  • row (Array<Float>)

    The current row as an array.

Returns:

  • (self)


150
151
# File 'lib/numerix/matrix3x2.rb', line 150

def each_row
end

#identity?Boolean

Returns true if the matrix is the identity matrix, otherwise false.

Returns:

  • (Boolean)

    true if the matrix is the identity matrix, otherwise false.



104
105
# File 'lib/numerix/matrix3x2.rb', line 104

def identity?
end

#invertMatrix3x2

Note:

Some matrices cannot be inverted, in which case the returned matrix will have all values set to NaN.

Attempts to invert the given matrix.

Returns:

  • (Matrix3x2)

    A new matrix that is this matrix inverted.



172
173
# File 'lib/numerix/matrix3x2.rb', line 172

def invert
end

#lerp(matrix, amount) ⇒ Matrix3x2

Linearly interpolates from this matrix to another, based on the amount.

Parameters:

  • matrix (Matrix3x2)

    The source matrix to interpolate between.

  • amount (Float)

    The relative weighting of the given matrix, clamped between 0.0 and 1.0.

Returns:

  • (Matrix3x2)

    a newly created interpolated matrix.

See Also:



185
186
# File 'lib/numerix/matrix3x2.rb', line 185

def lerp(matrix, amount)
end

#lerp!(matrix, amount) ⇒ self

Note:

This method is the same as #lerp, but alters the values of this matrix instead of creating a new instance.

Linearly interpolates from this matrix to another, based on the amount.

Parameters:

  • matrix (Matrix3x2)

    The source matrix to interpolate between.

  • amount (Float)

    The relative weighting of the given matrix, clamped between 0.0 and 1.0.

Returns:

  • (self)

See Also:



201
202
# File 'lib/numerix/matrix3x2.rb', line 201

def lerp!(matrix, amount)
end

#map {|component| ... } ⇒ Matrix3x2 Also known as: collect

The equivalent of Enumerable#map, but returns a matrix object instead of an Array.

Invokes the given block once for each element of self.

Creates a new matrix containing the values returned by the block.

Yields:

  • (component)

    Yields a component of the matrix to the block.

Yield Parameters:

  • component (Float)

    The yielded component.

Returns:

See Also:



71
72
# File 'lib/numerix/matrix3x2.rb', line 71

def map
end

#map! {|component| ... } ⇒ self Also known as: collect!

Invokes the given block once for each element of self, replacing the element with the value returned by the block.

The values of the matrix are altered without creating a ne object.

Yields:

  • (component)

    Yields a component of the matrix to the block.

Yield Parameters:

  • component (Float)

    The yielded component.

Returns:

  • (self)

See Also:



86
87
# File 'lib/numerix/matrix3x2.rb', line 86

def map!
end

#row(index) ⇒ Array<Float>?

Returns the specified matrix row as an array.

Parameters:

  • index (Integer)

    The row index to retrieve.

Returns:

  • (Array<Float>, nil)

    the requested row, or nil if index is out of range.

See Also:



126
127
# File 'lib/numerix/matrix3x2.rb', line 126

def row(index)
end

#to_aArray<Array<Float>> Also known as: elements

Returns an Array representation of this instance.

Returns:

  • (Array<Array<Float>>)

    an Array representation of this instance.



211
212
# File 'lib/numerix/matrix3x2.rb', line 211

def to_a
end

#to_hHash{Symbol => Float}

Returns a Hash representation of this instance.

Returns:

  • (Hash{Symbol => Float})

    a Hash representation of this instance.



218
219
# File 'lib/numerix/matrix3x2.rb', line 218

def to_h
end

#to_sString

Returns a String representation of this instance.

Returns:

  • (String)

    a String representation of this instance.



206
207
# File 'lib/numerix/matrix3x2.rb', line 206

def to_s
end