<jupyter_start><jupyter_text>Exploring & Testing Use of NURBS in DIC <NAME> Current: 12/7/18  Path and Imports<jupyter_code># bootstrap $PATH
import sys
import os
sys.path.extend(['C:\\Users\\potterst1\\Desktop\Repositories\BitBucket\dic',
                 'C:/Users/potterst1/Desktop/Repositories/BitBucket/dic'])
sys.path.extend(['/workspace/stpotter/git/bitbucket/dic'])
import warnings
from dic import nurbs
from dic import fileIO
from dic import numerics
from dic import analysis
from dic import image_processing
import cv2
from matplotlib import pyplot as plt
import numpy as np
import scipy.optimize as sciopt
from geomdl import BSpline as bs
from geomdl import utilities as gutil<jupyter_output><empty_output><jupyter_text>Magics<jupyter_code>%matplotlib inline<jupyter_output><empty_output><jupyter_text>Setup surface<jupyter_code>x = np.linspace(0, 1, 4)
y = np.linspace(0, 1, 4)
coords = np.zeros((len(x) * len(x), 2))
k = 0
for i in range(0, len(x)):
    for j in range(0, len(y)):
        coords[k, :] = np.array([x[i], y[j]])
        k += 1
coords
surf = bs.Surface()
surf.degree_u = 3
surf.degree_v = 3

num_ctrlpts = np.sqrt(len(coords)).astype('int')

surf.set_ctrlpts(coords.tolist(), num_ctrlpts, num_ctrlpts)

surf.knotvector_u = gutil.generate_knot_vector(surf.degree_u, num_ctrlpts)
surf.knotvector_v = gutil.generate_knot_vector(surf.degree_v, num_ctrlpts)

surf.delta = 0.003
pts = np.array(surf.evalpts)
len(pts)
pts[0, :]
pts[1, :]
surf.surfpt(0, 0.001)
pts[20, :]
surf.surfpt(0, 20 * 0.001)
np.sqrt(len(pts))
surf.surfpt(0.001, 20 * 0.001)
pts[1020, :]
len(np.arange(0, 1, 0.001))
surf.delta
surf.delta_u
surf.delta[0]
1020.0 % 1000.0
1020 // 1000
10000 // 1000
val = 0.5
A = np.random.random((4, 4))
A
X = np.abs(A-val)
X
point = [0.5, 0.5]
diff = np.sqrt(np.square(pts[:, 0] - point[0]) + np.square(pts[:, 1] - point[1]))
diff.shize
diff.size
diff.min()
idx = np.where(diff == diff.min())
idx
pts[idx[0], :]
foo = np.zeros((2,) + X.shape)
foo.shape
foo
surf.surfpt(0.0, 0.6)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1588785046728972, 'fraction_numerical': 0.05263157894736842, 'mean_word_length': 4.729577464788733, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '184083', 'license': 'MIT', 'n_tokens_mistral': 936, 'n_tokens_neox': 865, 'n_words': 184, 'path': 'notebooks/exploratory/stp_explore_Pixel_Parameterization.ipynb', 'repo_name': 'stpotter16/splineDIC', 'size': '2037'}