Find nearest SO(3) or orthogonal matrix.
nearest.Rd
Converts arbitrary 3 x 3 matrices into the nearest SO(3) or orthogonal matrix.
Details
Uses Stephens' (1979) algorithm to find the nearest (in entry-wise Euclidean sense) SO(3) or orthogonal matrix to a given matrix.
Value
nearest.SO3
produces an orientation-class
object holding the closest orientations.
nearest.orthog
produces a 3 x 3 x n array of orthogonal matrices.
Examples
x <- matrix(rnorm(9), 3,3)
nearest.orthog(x)
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 0.5590511 0.04878985 0.8276964
#> [2,] -0.3296190 -0.90291392 0.2758583
#> [3,] -0.7607977 0.42704332 0.4886930
#>
nearest.SO3(x)
#> An object of class "rotmatrix"
#> Slot "x":
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 0.5824788 -0.784314543 0.2134693
#> [2,] -0.3547565 -0.009004573 0.9349154
#> [3,] -0.7313455 -0.620298005 -0.2834857
#>
#>
x <- -x
nearest.orthog(x)
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] -0.5590511 -0.04878985 -0.8276964
#> [2,] 0.3296190 0.90291392 -0.2758583
#> [3,] 0.7607977 -0.42704332 -0.4886930
#>
nearest.SO3(x)
#> An object of class "rotmatrix"
#> Slot "x":
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] -0.5590511 -0.04878985 -0.8276964
#> [2,] 0.3296190 0.90291392 -0.2758583
#> [3,] 0.7607977 -0.42704332 -0.4886930
#>
#>