struct Chem::Spatial::AffineTransform

Defined in:

chem/spatial/affine.cr

Constructors

Instance Method Summary

Constructor Detail

def self.build(&block : Pointer(Float64) -> ) : self #

[View source]
def self.new(a : Vector, b : Vector, c : Vector, d : Vector = Vector.zero) #

[View source]
def self.new #

[View source]
def self.scaling(by factor : Number) : self #

[View source]
def self.scaling(by factors : ScalingFactors) : self #

[View source]
def self.translation(by offset : Vector) : self #

[View source]

Instance Method Detail

def *(rhs : self) : self #

[View source]
def *(rhs : Vector) : Vector #

[View source]
def ==(rhs : self) : Bool #

[View source]
def inner_det : Float64 #

Returns the determinant of the inner 3x3 rotation matrix


[View source]
def inspect(io : ::IO) #

[View source]
def inv : self #

Returns the inverse transformation

The algorithm exploits the fact that when a matrix looks like this

A = [ M   b  ]
    [ 0   1  ]

where A is 4x4 (augmented matrix), M is 3x3 (rotation matrix), b is 3x1 (translation vector), and the bottom row is (0, 0, 0, 1), then

inv(A) = [ inv(M)   -inv(M) * b ]
         [   0            1     ]

inv(M) is computed following the standard procedure (see Wikipedia, Inversion of 3x3 matrices).

Refer to https://stackoverflow.com/a/2625420 or Wikipedia, Affine transformation article (Properties section) for a detailed explanation.


[View source]
def scale(by factor : Number) : self #

[View source]
def scale(by factors : ScalingFactors) : self #

[View source]
def to_a : Array(Float64) #

[View source]
def to_unsafe : Pointer(Float64) #

[View source]
def translate(by offset : Vector) : self #

[View source]
def unsafe_fetch(index : Int) : Float64 #

[View source]