struct Chem::Spatial::AffineTransform
- Chem::Spatial::AffineTransform
- Struct
- Value
- Object
Defined in:
chem/spatial/affine.crConstructors
- .build(&block : Pointer(Float64) -> ) : self
- .new(a : Vector, b : Vector, c : Vector, d : Vector = Vector.zero)
- .new
- .scaling(by factor : Number) : self
- .scaling(by factors : ScalingFactors) : self
- .translation(by offset : Vector) : self
Instance Method Summary
- #*(rhs : self) : self
- #*(rhs : Vector) : Vector
- #==(rhs : self) : Bool
-
#inner_det : Float64
Returns the determinant of the inner 3x3 rotation matrix
- #inspect(io : ::IO)
-
#inv : self
Returns the inverse transformation
- #scale(by factor : Number) : self
- #scale(by factors : ScalingFactors) : self
- #to_a : Array(Float64)
- #to_unsafe : Pointer(Float64)
- #translate(by offset : Vector) : self
- #unsafe_fetch(index : Int) : Float64
Constructor Detail
Instance Method Detail
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.