{{ message }}

Instantly share code, notes, and snippets.

# Donald Munro donaldmunro

Created Mar 5, 2017
Display/print a GLM mat or vec
View gist:38841d72c65a1c32f2bf83a4a00a2c9a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include .. .. glm::mat4 mat; .. .. std::cout << glm::to_string(mat) << std::endl;
Created Nov 20, 2021
View sage-ext.md
``````clear_vars
reset()
%display latex

u,v,w,T = SR.var('x y z t')
E_x,E_y,E_z  = function('Ex'),function('Ey'), function('Ez')
B_x,B_y,B_z  = function('Bx'),function('By'), function('Bz')
M.<t, x, y, z> = manifolds.Minkowski(positive_spacelike=False)
F = M.diff_form(2, name='F')
``````
Last active Nov 9, 2021
Compile Boost for Android
View boost-android.md

# Compiling Boost for Android

2. Create Android toolchains for desired architectures by running a script as below:

```NDK=/opt/android-sdk/ndk-bundle/
TOOLCHAINS="\$PWD/toolchains/"```

rm -rf \$TOOLCHAINS

Last active Aug 3, 2021
Differential Forms on simple Euclidean manifolds using SageMath Manifolds package
View euclidean_forms.md
``````clear_vars
reset()
%display latex
R3 = Manifold(3, 'R^3', start_index=1)
X.<x,y,z> = R3.chart()
g = R3.metric('g')
g[1,1], g[2,2], g[3,3] = 1, 1, 1

#R2 = Manifold(2, 'R^2', ambient=R3, start_index=1)
``````
Created Jan 28, 2018
View kotlin-jni-javah.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Using javah to generate .h files for Kotlin # Assuming JNI function calls are in MainActivity.companion STUDIO=/opt/android-studio PACKAGE=my.package \$STUDIO/jre/bin/javah -jni -cp "\$STUDIO/lib/kotlin-runtime.jar:build/tmp/kotlin-classes/debug" \$PACKAGE.MainActivity.Companion
Created Jan 26, 2019
A wrapped std::multimap which limits size by removing the smallest keys first. Useful for timestamped data where the oldest items (smallest timestamps) can be removed.
View bounded_map.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #ifndef _BOUNDED_MAP_H #define _BOUNDED_MAP_H #include #include #include #include /** * A wrapped std::multimap which limits size by removing the smallest keys first.
Created Feb 24, 2017
Map OpenCv Mat to Eigen Matrix and calculate Eigenvectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include .. .. using RowMatrixXf = Eigen::Matrix; Eigen::Map mapped(extended_homograpy.ptr(), homography.rows, homography.cols); Eigen::EigenSolver eigen_solve(mapped, true); auto ev = eigen_solve.eigenvectors(); std::cout << "No of EigenVectors = " << ev.cols() << std::endl; for (auto i=0; i
Created Mar 5, 2017
Access/dereference glm::mat4 contents
View gist:a2a0a061de498b9dc0ec10be309de2b7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include .. glm::mat4 m = glm::mat4(1.0f); .. auto p = glm::value_ptr(m); std::cout << sizeof(p) << std::endl; glUniformMatrix4fv(shader_uniform_m, 1, GL_FALSE, p);
Created Feb 25, 2017
Parse delimited string in C++
View gist:afa2f57bd4e52aa3cc0e3bbe422c889e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 size_t split(std::string s, std::vector& tokens, std::string delim ="\t\n ") { tokens.clear(); size_t pos = s.find_first_not_of(delim); while (pos != std::string::npos) { size_t next = s.find_first_of(delim, pos); if (pos == std::string::npos) tokens.emplace_back(s.substr(pos));
Last active Jan 10, 2016
Benchmark OpenCV Feature/Descriptor Extractors.
View features.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* Copyright (c) 2016, Donald Munro Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR