Blender  V3.3
Classes | Functions
btImplicitQRSVD.h File Reference
#include <limits>
#include "btMatrix3x3.h"

Go to the source code of this file.

Classes

class  btMatrix2x2
 
class  GivensRotation
 

Functions

static btScalar copySign (btScalar x, btScalar y)
 
void zeroChase (btMatrix3x3 &H, btMatrix3x3 &U, btMatrix3x3 &V)
 zero chasing the 3X3 matrix to bidiagonal form original form of H: x x 0 x x x 0 0 x after zero chase: x x 0 0 x x 0 0 x More...
 
void makeUpperBidiag (btMatrix3x3 &H, btMatrix3x3 &U, btMatrix3x3 &V)
 make a 3X3 matrix to upper bidiagonal form original form of H: x x x x x x x x x after zero chase: x x 0 0 x x 0 0 x More...
 
void makeLambdaShape (btMatrix3x3 &H, btMatrix3x3 &U, btMatrix3x3 &V)
 make a 3X3 matrix to lambda shape original form of H: x x x x x x x x x after : x 0 0 x x 0 x 0 x More...
 
void polarDecomposition (const btMatrix2x2 &A, GivensRotation &R, const btMatrix2x2 &S_Sym)
 2x2 polar decomposition. More...
 
void polarDecomposition (const btMatrix2x2 &A, const btMatrix2x2 &R, const btMatrix2x2 &S_Sym)
 
void singularValueDecomposition (const btMatrix2x2 &A, GivensRotation &U, const btMatrix2x2 &Sigma, GivensRotation &V, const btScalar tol=64 *std::numeric_limits< btScalar >::epsilon())
 2x2 SVD (singular value decomposition) A=USV' More...
 
void singularValueDecomposition (const btMatrix2x2 &A, const btMatrix2x2 &U, const btMatrix2x2 &Sigma, const btMatrix2x2 &V, const btScalar tol=64 *std::numeric_limits< btScalar >::epsilon())
 2x2 SVD (singular value decomposition) A=USV' More...
 
btScalar wilkinsonShift (const btScalar a1, const btScalar b1, const btScalar a2)
 compute wilkinsonShift of the block a1 b1 b1 a2 based on the wilkinsonShift formula mu = c + d - sign (d) \ sqrt (d*d + b*b), where d = (a-c)/2 More...
 
template<int t>
void process (btMatrix3x3 &B, btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V)
 Helper function of 3X3 SVD for processing 2X2 SVD. More...
 
void flipSign (int i, btMatrix3x3 &U, btVector3 &sigma)
 Helper function of 3X3 SVD for flipping signs due to flipping signs of sigma. More...
 
void flipSign (int i, btMatrix3x3 &U)
 
void swapCol (btMatrix3x3 &A, int i, int j)
 
void sort (btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
 Helper function of 3X3 SVD for sorting singular values. More...
 
int singularValueDecomposition (const btMatrix3x3 &A, btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, btScalar tol=128 *std::numeric_limits< btScalar >::epsilon())
 3X3 SVD (singular value decomposition) A=USV' More...
 

Function Documentation

◆ copySign()

static btScalar copySign ( btScalar  x,
btScalar  y 
)
inlinestatic

Definition at line 90 of file btImplicitQRSVD.h.

References x, and y.

Referenced by wilkinsonShift().

◆ flipSign() [1/2]

void flipSign ( int  i,
btMatrix3x3 U 
)
inline

Definition at line 653 of file btImplicitQRSVD.h.

◆ flipSign() [2/2]

void flipSign ( int  i,
btMatrix3x3 U,
btVector3 sigma 
)
inline

Helper function of 3X3 SVD for flipping signs due to flipping signs of sigma.

Definition at line 645 of file btImplicitQRSVD.h.

Referenced by sort().

◆ makeLambdaShape()

void makeLambdaShape ( btMatrix3x3 H,
btMatrix3x3 U,
btMatrix3x3 V 
)
inline

make a 3X3 matrix to lambda shape original form of H: x x x x x x x x x after : x 0 0 x x 0 x 0 x

Reduce H to of form x x 0 x x x x x x

Reduce H to of form x x 0 x x 0 x x x

Reduce H to of form x x 0 x x 0 x 0 x

Reduce H to of form x 0 0 x x 0 x 0 x

Definition at line 372 of file btImplicitQRSVD.h.

References GivensRotation::columnRotation(), GivensRotation::computeUnconventional(), H, GivensRotation::rowRotation(), and V.

◆ makeUpperBidiag()

void makeUpperBidiag ( btMatrix3x3 H,
btMatrix3x3 U,
btMatrix3x3 V 
)
inline

make a 3X3 matrix to upper bidiagonal form original form of H: x x x x x x x x x after zero chase: x x 0 0 x x 0 0 x

Reduce H to of form x x x x x x 0 x x

Definition at line 342 of file btImplicitQRSVD.h.

References H, r, V, and zeroChase().

Referenced by singularValueDecomposition().

◆ polarDecomposition() [1/2]

void polarDecomposition ( const btMatrix2x2 A,
const btMatrix2x2 R,
const btMatrix2x2 S_Sym 
)
inline

Definition at line 453 of file btImplicitQRSVD.h.

References A, polarDecomposition(), R, and r.

◆ polarDecomposition() [2/2]

void polarDecomposition ( const btMatrix2x2 A,
GivensRotation R,
const btMatrix2x2 S_Sym 
)
inline

2x2 polar decomposition.

Parameters
[in]Amatrix.
[out]RRobustly a rotation matrix.
[out]S_SymSymmetric. Whole matrix is stored

Polar guarantees negative sign is on the small magnitude singular value. S is guaranteed to be the closest one to identity. R is guaranteed to be the closest rotation to A.

Definition at line 431 of file btImplicitQRSVD.h.

References A, Freestyle::a, usdtokens::b(), btSqrt(), R, and SIMD_EPSILON.

Referenced by polarDecomposition(), and singularValueDecomposition().

◆ process()

template<int t>
void process ( btMatrix3x3 B,
btMatrix3x3 U,
btVector3 sigma,
btMatrix3x3 V 
)
inline

◆ singularValueDecomposition() [1/3]

void singularValueDecomposition ( const btMatrix2x2 A,
const btMatrix2x2 U,
const btMatrix2x2 Sigma,
const btMatrix2x2 V,
const btScalar  tol = 64 * std::numeric_limits<btScalar>::epsilon() 
)
inline

2x2 SVD (singular value decomposition) A=USV'

Parameters
[in]AInput matrix.
[out]URobustly a rotation matrix.
[out]SigmaVector of singular values sorted with decreasing magnitude. The second one can be negative.
[out]VRobustly a rotation matrix.

Definition at line 549 of file btImplicitQRSVD.h.

References A, GivensRotation::fill(), singularValueDecomposition(), and V.

◆ singularValueDecomposition() [2/3]

void singularValueDecomposition ( const btMatrix2x2 A,
GivensRotation U,
const btMatrix2x2 Sigma,
GivensRotation V,
const btScalar  tol = 64 * std::numeric_limits<btScalar>::epsilon() 
)
inline

2x2 SVD (singular value decomposition) A=USV'

Parameters
[in]AInput matrix.
[out]URobustly a rotation matrix in Givens form
[out]Sigmamatrix of singular values sorted with decreasing magnitude. The second one can be negative.
[out]VRobustly a rotation matrix in Givens form

Definition at line 469 of file btImplicitQRSVD.h.

References A, btSqrt(), polarDecomposition(), btMatrix2x2::setIdentity(), SIMD_EPSILON, swap(), t, V, w(), x, y, and z.

Referenced by btDeformableLinearElasticityForce::addScaledElasticForce(), btDeformableNeoHookeanForce::addScaledElasticForce(), btSoftBody::getRigidTransform(), process(), and singularValueDecomposition().

◆ singularValueDecomposition() [3/3]

int singularValueDecomposition ( const btMatrix3x3 A,
btMatrix3x3 U,
btVector3 sigma,
btMatrix3x3 V,
btScalar  tol = 128*std::numeric_limits<btScalar>::epsilon() 
)
inline

3X3 SVD (singular value decomposition) A=USV'

Parameters
[in]AInput matrix.
[out]Uis a rotation matrix.
[out]sigmaDiagonal matrix, sorted with decreasing magnitude. The third one can be negative.
[out]Vis a rotation matrix.

Do implicit shift QR until A^T A is block diagonal

Handle the cases of one of the alphas and betas being 0 Sorted by ease of handling and then frequency of occurrence

If B is of form x x 0 0 x 0 0 0 x

If B is of form x 0 0 0 x x 0 0 x

If B is of form x x 0 0 0 x 0 0 x

Reduce B to x x 0 0 0 0 0 0 x

If B is of form x x 0 0 x x 0 0 0

Reduce B to x x + 0 x 0 0 0 0

Reduce B to x x 0

  • x 0 0 0 0

If B is of form 0 x 0 0 x x 0 0 x

Reduce B to 0 0 + 0 x x 0 0 x

Reduce B to 0 0 0 0 x x 0 + x

Definition at line 750 of file btImplicitQRSVD.h.

References A, B, btFabs(), btMatrix3x3, btMax(), btSqrt(), GivensRotation::columnRotation(), GivensRotation::compute(), GivensRotation::computeUnconventional(), count, makeUpperBidiag(), r, GivensRotation::rowRotation(), SIMD_EPSILON, sort(), V, wilkinsonShift(), and zeroChase().

◆ sort()

void sort ( btMatrix3x3 U,
btVector3 sigma,
btMatrix3x3 V,
int  t 
)
inline

Helper function of 3X3 SVD for sorting singular values.

Definition at line 668 of file btImplicitQRSVD.h.

References btFabs(), flipSign(), swap(), swapCol(), t, and V.

Referenced by AnimationImporter::add_bone_animation_sampled(), AnimationImporter::apply_matrix_curves(), attr_create_pointiness(), BLI_string_search_query(), bvh_reference_sort(), bvh_reference_sort_threaded(), Freestyle::ViewMapBuilder::ComputeSweepLineIntersections(), blender::io::gpencil::GpencilIO::create_object_list(), mv::AutoTrack::DetectAndTrack(), ED_transform_snap_object_project_all_view3d_ex(), ED_transform_snap_object_project_ray_all(), filelist_setsorting(), blender::index_mask_ops::detail::find_indices_based_on_predicate__merge(), NamedSizeStats::full_report(), NamedTimeStats::full_report(), NamedSampleCountStats::full_report(), NamedNestedSampleStats::full_report(), btSoftBodyHelpers::generateBoundaryFaces(), mv::Tracks::GetMarkersForTracksInBothImages(), blender::nodes::geometry_nodes_eval_log::GFieldValueLog::GFieldValueLog(), initial_triangulation(), internal_dependencies_panel_draw(), libmv::Tracks::MarkersForTracksInBothImages(), blender::ed::space_node::named_attribute_tooltip(), blender::nodes::node_geo_attribute_statistic_cc::node_geo_exec(), blender::nodes::node_geo_collection_info_cc::node_geo_exec(), blender::nodes::NodeTreeRef::NodeTreeRef(), mv::PredictMarkerPosition(), remove_non_constraint_edges_leave_valid_bmesh(), singularValueDecomposition(), blender::ed::space_node::snode_autoconnect(), btReducedVector::sort(), Freestyle::Operators::sort(), blender::ed::space_node::sort_multi_input_socket_links(), test_sin_cos_from_fraction_symmetry(), AnimationImporter::translate_animation_OLD(), WM_operator_properties_filesel(), blender::io::obj::MTLWriter::write_materials(), and DeviceQueue::~DeviceQueue().

◆ swapCol()

void swapCol ( btMatrix3x3 A,
int  i,
int  j 
)
inline

Definition at line 660 of file btImplicitQRSVD.h.

References A, and swap().

Referenced by sort().

◆ wilkinsonShift()

btScalar wilkinsonShift ( const btScalar  a1,
const btScalar  b1,
const btScalar  a2 
)
inline

compute wilkinsonShift of the block a1 b1 b1 a2 based on the wilkinsonShift formula mu = c + d - sign (d) \ sqrt (d*d + b*b), where d = (a-c)/2

Definition at line 572 of file btImplicitQRSVD.h.

References btFabs(), btSqrt(), copySign(), and SIMD_EPSILON.

Referenced by singularValueDecomposition().

◆ zeroChase()

void zeroChase ( btMatrix3x3 H,
btMatrix3x3 U,
btMatrix3x3 V 
)
inline

zero chasing the 3X3 matrix to bidiagonal form original form of H: x x 0 x x x 0 0 x after zero chase: x x 0 0 x x 0 0 x

Reduce H to of form x x + 0 x x 0 0 x

Reduce H to of form x x 0 0 x x 0 + x Can calculate r2 without multiplying by r1 since both entries are in first two rows thus no need to divide by sqrt(a^2+b^2)

Reduce H to of form x x 0 0 x x 0 0 x

Definition at line 286 of file btImplicitQRSVD.h.

References GivensRotation::columnRotation(), GivensRotation::compute(), H, GivensRotation::rowRotation(), and V.

Referenced by makeUpperBidiag(), and singularValueDecomposition().