import trimesh
from numpy.linalg import inv
import numpy as np
def pretty_print(array):
print(np.round(array, 2))
def change_centroid(mesh_path, save_path, additional_T=None):
mesh = trimesh.load_mesh(mesh_path)
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
from multiprocessing import Pool | |
import numpy as np | |
import time | |
def gen_data(s, e, N): | |
q = np.linspace(s, e, N) | |
dq = np.linspace(s, e, N)*2 | |
ddq = np.linspace(s, e, N)*3 | |
time.sleep(0.5) |
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
T* constructOrFindInstance(const std::string& instance_name) | |
{ | |
auto result = mSegment.find<T>(instance_name.c_str()); | |
if (result.first != nullptr) { | |
return result.first; | |
} else { | |
return mSegment.construct<T>(instance_name.c_str())(); | |
} | |
} |
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
import numpy as np | |
def two_d_array_compare(array_a, array_b, thresh): | |
""" | |
this function does a pairwise comparision matching between array_b and array_a | |
it returns all the row numbers in array_a that has a similar entry in array_b | |
:param array_a: m x k | |
:param array_b: n x k | |
:thresh float difference | |
:return: row numbers of similar rows |
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
#!/usr/bin/bash | |
input="full path to file" | |
while IFS= read -r line; do | |
arrIN=(${line// / }) ## to split with ; arrIN=(${line//;/ }) | |
## do something with the words, words can be obtained by ${arrIN[i]} where i is the index | |
done < "${input}" |
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
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
def plot_cuboid(sample_cuboid): | |
fig = plt.figure(figsize=(12,9)) | |
ax = fig.add_subplot(111, projection='3d') | |
for pair in sampling_cuboid['plot_pairs']: | |
start_point = sampling_cuboid['centre_point'] + sampling_cuboid[pair[0]] | |
end_point = sampling_cuboid['centre_point'] + sampling_cuboid[pair[1]] |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
x_min = 0.51 | |
x_max = 0.54 | |
num_bins = 20 | |
num_data=7000 | |
x_mean = 0.53 | |
plt.style.use("ggplot") |
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
function compress_pdf() | |
{ | |
input_file=$1 | |
output_file=$1_compressed.pdf | |
level=/$2 | |
#levels: screen > ebook > printer > prepress, | |
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=$level -sOutputFile=$output_file $input_file | |
echo "Saved in the same folder with name $output_file" | |
} |
NewerOlder