Skip to content

Instantly share code, notes, and snippets.

View ArashJavan's full-sized avatar

Arash ArashJavan

View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import open3d as o3d
import pykitti
def get_quadrant(point):
res = 0
x = point[0]
@ArashJavan
ArashJavan / kitti_seg_kmean.py
Last active January 17, 2020 14:56
KITTI K-Mean segmentation
import copy
import datetime
import numpy as np
import sklearn
import open3d as o3d
import matplotlib
from matplotlib import pyplot as plt
from sklearn import decomposition
@ArashJavan
ArashJavan / gist:440c8630237df214ff307c8cb54750af
Created November 12, 2019 21:06
Quaternoin from two vectors
import numpy as np
import scipy
from scipy.spatial.transform import Rotation
import pyquaternion
def quaternon_from_two_vectors(a, b):
a_n = a / np.linalg.norm(a)
b_n = b / np.linalg.norm(b)
@ArashJavan
ArashJavan / bernstein bezier polynomial curve interpolation
Created July 12, 2018 12:02
paramteric bernstein bezier polynomial curve interpolation
import numpy as np
import scipy
import scipy.special
import matplotlib.pyplot as plt
def get_weights(n):
W = []
for i in np.arange(n):
def berstein_poly(t, i=i, n=n-1):
@ArashJavan
ArashJavan / hermite_curve_interpolation_1
Created July 6, 2018 07:25
hermitian curve interpolation
import numpy as np
import matplotlib.pyplot as plt
p0 = np.array([0, 0])
p1 = np.array([1, 0])
p0t = np.array([1, 1])
p1t = np.array([-1, -1])
P = np.array([p0, p1, p0t, p1t])
H = np.array([[2, -2, 1, 1], [-3, 3, -2, -1], [0, 0, 1, 0], [1, 0, 0, 0]])
@ArashJavan
ArashJavan / bicubic_surface
Created July 4, 2018 14:34
bicubic polynomial surface using 16 points
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
P00 = np.array([0, 0, 0])
P01 = np.array([1, 0, 0])
P02 = np.array([2, 0, 0])
P03 = np.array([3, 0, 0])
@ArashJavan
ArashJavan / biquadratic_surface_interpoaltion
Created July 4, 2018 14:26
Biquadratic Surface Patch using nine points
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
P00 = np.array([0, 0, 0])
P01 = np.array([1, 0, 0])
P02 = np.array([2, 0, 0])
P10 = np.array([0, 1, 2])
@ArashJavan
ArashJavan / lagrange_polynomial
Last active July 4, 2018 11:53
lagrange polynomial interpolation
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
# number of points
num = 4
dim = 3
min = -20
max = 20
@ArashJavan
ArashJavan / bilinear_surface.py
Last active June 28, 2018 09:45
Creating bilinear surface and the normals using bernstein polynomial
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
P = lambda u, w, P00, P01, P10, P11: P00 * (1 - u) * (1 - w) + P01 * w * (1 - u) + P10 * u * (1 - w) + P11 * u * w
dpdu = lambda w, P00, P01, P10, P11: w * (P11 - P01 - P10 + P00) + P10 - P00
dpdw = lambda u, P00, P01, P10, P11: u * (P11 - P01 - P10 + P00) + P01 - P00
N = lambda u, w, P00, P01, P10, P11: np.cross(dpdu(w, P00, P01, P10, P11), dpdw(u, P00, P01, P10, P11))