# -*- coding: utf-8 -*-
import math,csv
import numpy as np
import sympy as sy
from scipy.stats import norm,uniform

import matplotlib.pyplot as plt
from IPython.display import display,Image, SVG, Math
from IPython.core.pylabtools import print_figure

#x,y,z=np.loadtxt('C:\Users\diego2\Desktop\RETOP\HEAD\head2.obj', delimiter=' ',usecols=(1,2,3), unpack=True)
coords = np.array([
    [ 0.077252, -2.730363, -2.455086, -2.131931, -0.517992, -1.907237, -1.283062, -1.712348, -2.705659, -1.18497 , -2.91046 , -1.056548,  0.057986, -1.528712, -2.255293, -2.674014, -2.748361, -2.793338, -2.784614, -2.588411, -1.590086, -1.528858, -1.435086, -1.329954, -1.243716, -1.21035 , -1.592772, -2.250905, -1.979815, -3.071889, -3.090177,  0.075568,  0.06467 ,  0.085789,  0.073043,  0.084593,  0.070529,  0.065637,  0.065959,  0.067892,  0.06981 ,  0.065639,  0.069495,  0.061538,  0.07804 ,  0.06732 ,  0.06709 ,  0.072134,  0.067404,  0.067558,  0.067404,  0.066761,  0.067568,  0.067491,  0.070066,  0.075541,  0.076222,  0.056815,  0.071721,  0.073386,  0.07276 ,  0.067691,  0.06773 ,  0.067649,  0.06729 ,  0.068578,  0.069322,  0.067444,  0.067041,  0.066901,  0.066832,  0.066199,  0.065798,  0.065879,  0.065918,  0.066681,  0.067404,  0.067482,  0.066114,  0.065392,  0.065032,  0.065154,  0.065396,  0.065517,  0.065578,  0.067724,  0.068768,  0.071013,  0.071773,  0.072152,  0.072341,  0.072437,  0.072484,  0.072508,  0.074809,  0.075191,  0.073047,  0.075005,  0.074908,  0.085073,  0.076791,  0.074293,  0.071555,  0.07081 ,  0.06895 ,  0.067834,  0.067591,  0.067791,  0.06769 ,  0.067609,  0.067506,  0.067537,  0.066971,  0.066866,  0.06648 ,  0.065918,  0.065717,  0.065838,  0.065858,  0.065868,  0.065899,  0.065939,  0.06632 ,  0.066501,  0.067043,  0.067404,  0.067404,  0.067404,  0.069861,  0.046576,  0.065608,  0.068246,  0.067985,  0.071393,  0.06752 ,  0.065212,  0.064851,  0.067442,  0.067462,  0.054057],
    [ 0.12396 , -0.010649, -0.01, -0.01, -0.010026, -0.010015, -0.010403, -0.010005, -0.01    , -0.010752, -0.015246, -0.010021, -0.090334, -0.010018, -0.010008, -0.01    , -0.01    , -0.01    , -0.01    , -0.01    , -0.013166, -0.013858, -0.012878, -0.011403, -0.010544, -0.01319 , -0.013598, -0.01187 , -0.012531, -0.01363 , -0.01262 ,  3.341047, -3.013938,  3.766831, -2.644764, -1.482959,  3.203447, -3.777567, -3.290315, -3.052378, -1.64998 , -2.817306, -1.37134 ,  0.958978, -2.052327, -3.427496, -3.125557,  3.425294, -3.230033, -3.259598, -3.245542, -3.788567, -3.118843, -3.172829, -2.85772 , -2.395945,  2.938024,  3.33605 ,  3.894187,  3.875574,  3.728934, -3.133723, -3.036806, -3.056704, -3.156727, -3.068899, -2.953659, -3.299387, -3.547877, -3.674725, -3.762305, -3.791442, -3.69267 , -3.492695, -3.382389, -3.202756, -3.326953, -3.219615, -3.24121 , -3.175147, -3.102887, -3.006557, -2.987023, -2.974252, -2.909322, -2.661753, -1.978603, -1.245686, -1.084813, -1.008996, -0.717055, -0.551152, -0.397736, -0.14826 ,  2.824199,  3.642328,  3.211923,  3.818439,  3.588235, -0.701429, -2.257913, -2.533723, -2.738298, -2.803874, -3.009485, -3.100939, -3.147107, -3.077183, -3.029008, -3.076993, -3.218579, -3.14661 , -3.600853, -3.7147  , -3.796522, -3.787362, -3.734501, -3.649597, -3.603422, -3.551657, -3.442321, -3.329333, -3.281824, -3.226953, -3.185524, -3.246189, -3.303955, -3.31369 ,  3.585227,  2.353651, -2.91105 , -2.225993, -2.423545, -1.148071, -3.233832, -3.154912, -3.061304, -3.190185, -3.164489,  1.741081],
    [-4.244369, -3.986893,  3.651353, -0.407608,  4.795705,  4.203277,-2.537347, -1.199492,  1.571151, -3.012362, -4.166567,  4.706279,4.69503 ,  4.474286,  3.8922  ,  3.196505,  2.746684,  2.311083,  1.913805,  0.674289, -1.445311, -1.695009, -2.009364, -2.307319, -2.779657, -3.144098, -3.325836, -3.692575, -3.538193, -4.313759, -4.416241, -2.026093, -1.776999,  2.39676 ,  3.069445,  4.224234,-0.669209,  0.030644, -0.219445,  1.537116, -2.400254, -2.400256, -2.448674,  4.539564,  3.798467,  0.907377,  1.890635, -0.082009, -0.980289, -1.325129, -0.67284 ,  0.254827,  1.204909,  1.758263, 2.483055,  3.413158,  3.718053,  3.337285,  1.950939,  1.435048, 0.652766,  1.643336,  1.477165,  1.326597,  1.812996,  2.084084, 2.296972,  1.05138 ,  0.66254 ,  0.470123,  0.318462,  0.144574, -0.073859, -0.143155, -0.182191, -0.457575, -0.839068, -1.151194, -1.3886  , -1.443773, -1.590055, -1.865812, -1.988449, -2.079232, -2.181324, -2.506514, -2.445968, -2.479641, -2.72082 , -2.893346, -3.146029, -3.278584, -3.486893, -3.737609, -4.25294 , -2.526031, -1.539587, -2.759768, -3.59271 ,  4.470358,  3.567291,  3.250914, 2.870492,  2.640371,  2.18997 ,  1.950093,  1.704795,  1.600065, 1.392418,  1.262399,  1.110395,  1.168512,  0.565052,  0.397049, 0.197778,  0.081584, -0.022786, -0.094747, -0.11483 , -0.127873, -0.162173, -0.194119, -0.2713  , -0.356387, -0.605803, -0.94093 , -0.898382, -0.752342,  2.871637,  4.150448, -2.281879, -2.478826, -2.522743, -2.564075, -1.210738, -1.519811, -1.673404, -1.019556, -1.068055,  4.39072 ]])

vertical = [44,140,130,57,58,129,34,59,60,61,48,37,97,32,96,98,99,95,1,13,100,13,1,94,93,92,91,90,89,134,88,43,41,87,132,133,86,42,131,85,84,83,82,33,137,81,136,80,79,50,135,78,139,138,49,126,127,77,128,51,125,76,124,123,39,122,75,121,74,120,119,118,73,117,38,116,72,115,52,71,114,70,113,69,46,68,111,112,53,110,64,109,63,40,108,62,107,54,65,47,106,66,105,67,55,104,103,35,102,56,101,45,36]
horizontal = [11,30,31,1,13,5,12,14,6,15,3,16,17,18,19,9,20,4,8,21,22,23,24,7,25,10,26,27,29,28,2]

vertical_recount = [v-1 for v in vertical]
horizontal_recount = [v-1 for v in horizontal]

V_x,V_y,V_z = np.array([coords.take(v,axis=1) for v in vertical_recount]).transpose(1,0)
H_x,H_y,H_z = np.array([coords.take(v,axis=1) for v in horizontal_recount]).transpose(1,0)

print("Vertex count:%i" % coords.size)
print("Vertical vertex:%i" % len(vertical))
print("Horizontal vertex:%i" % len(horizontal))

plt1 = plt.scatter(V_y,V_z, s=5)
ax2 = plt.gca()
ax2.set_xlim(-5,5)
ax2.set_ylim(-5,5)
fig1 = plt.figure()
plt2 = plt.scatter(H_x,H_z, s=15)
ax = plt.gca()
ax.set_xlim(-5,5)
ax.set_ylim(-5,5)
fig2 = plt.figure()
