Skip to content

Instantly share code, notes, and snippets.

@gocarlos
gocarlos / Eigen Cheat sheet
Last active February 11, 2024 14:07
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@nicolov
nicolov / tilt_torsion.py
Created August 9, 2016 16:58
Tilt-torsion decomposition for rotation matrices
import numpy as np
from tf.transformations import *
def tilt_torsion_decomposition(R):
z_axis = [0, 0, 1]
target_z = np.dot(R.T, z_axis)
axis = np.cross(z_axis, target_z)
angle = np.arctan2(np.linalg.norm(axis), np.dot(z_axis, target_z))
R_tilt = quaternion_matrix(quaternion_about_axis(angle, axis))[:3, :3]
R_torsion = np.dot(R, R_tilt.T)
@rbabich
rbabich / levmarq - Levenberg-Marquardt in plain C
Last active March 14, 2023 15:26
A simple implementation of the Levenberg-Marquardt algorithm in plain C
This file (with a leading space) exists so that the gist has a sensible name, rather than "LICENSE."
@inspirit
inspirit / HomographyDecomposition.as
Created December 14, 2010 19:57
Decompose Homography into Rotation matrix & Translation vector
var intrinsic:Vector.<Number> = new Vector.<Number>(9, true);
var intrinsicInverse:Vector.<Number> = new Vector.<Number>(9, true);
var R:Vector.<Number> = new Vector.<Number>( 9, true );
var t:Vector.<Number> = new Vector.<Number>( 3, true );
// SVD routine
var svd:SVD = new SVD();
// input homography[9] - 3x3 Matrix