diff --git a/aquapointer/analog/example_output/DNA/locations.txt b/aquapointer/analog/example_output/DNA/locations.txt index 4314a52..9bfb2e9 100644 --- a/aquapointer/analog/example_output/DNA/locations.txt +++ b/aquapointer/analog/example_output/DNA/locations.txt @@ -1,54 +1,56 @@ --2.756142556855718517e+00 1.354920562525641969e+01 0.000000000000000000e+00 --1.047147058801445318e+00 2.352878444022545779e+01 0.000000000000000000e+00 -4.016717189474495520e+00 1.854058849629642225e+01 0.000000000000000000e+00 -5.722686456105194885e+00 2.455357978892999427e+01 0.000000000000000000e+00 -1.212054703548348300e+01 2.525613816105845899e+01 0.000000000000000000e+00 --1.114945446711380406e+00 -2.703824536404827228e+00 0.000000000000000000e+00 -1.761236291036447810e+01 -4.055076503473845406e+00 0.000000000000000000e+00 -1.553401154917657934e+01 1.840101186329108174e+01 0.000000000000000000e+00 -2.147900321219054831e+01 1.724230185777556557e+01 0.000000000000000000e+00 -2.184302593273469739e+01 7.040898707469452233e+00 0.000000000000000000e+00 -2.037595619838770489e+01 1.669602810484185795e+01 0.000000000000000000e+00 -2.499741978844848944e+01 1.232623715149915711e+01 0.000000000000000000e+00 -2.544582969029707442e+01 3.528216123293024253e+00 0.000000000000000000e+00 --1.410293862443409374e+00 4.509433664374832063e+00 0.000000000000000000e+00 --1.485056462025398538e+00 2.263226092466903339e+01 0.000000000000000000e+00 --5.101973771589817908e+00 1.230881216691198787e+01 0.000000000000000000e+00 -1.106429643416246122e+01 -1.617539392970563483e+00 0.000000000000000000e+00 -1.875244977974125504e+01 2.114889461875506527e-01 0.000000000000000000e+00 -5.673626431028653272e-01 -6.738723827780811249e+00 0.000000000000000000e+00 -8.624999846439180828e+00 -6.970004925451648958e+00 0.000000000000000000e+00 --8.183536092010061935e+00 -3.416648448268134075e+00 0.000000000000000000e+00 -1.971500596982004083e+01 -5.303005442993052654e+00 0.000000000000000000e+00 --6.228267153208107310e+00 2.251714103496485819e+01 0.000000000000000000e+00 -2.081404904575121861e+01 5.035103647560518425e+00 0.000000000000000000e+00 --8.576812067190221711e+00 6.893019292120101227e+00 0.000000000000000000e+00 --2.739845737677669923e+00 3.710349322562588981e+00 0.000000000000000000e+00 -2.098055293902489638e+01 1.666398137908238652e+01 0.000000000000000000e+00 -1.973378569620428635e+01 2.514792000037411412e+01 0.000000000000000000e+00 -1.660788991728307806e+01 -1.830153675168137539e+00 0.000000000000000000e+00 --6.104431678915285708e+00 -6.387102450719634561e+00 0.000000000000000000e+00 -5.875927111549224868e+00 -8.754934445696751055e+00 0.000000000000000000e+00 -1.055277211618181710e+01 -3.021248161357995343e+00 0.000000000000000000e+00 -1.929404493871951587e+01 -7.319149061084186059e+00 0.000000000000000000e+00 --8.945291165270955247e+00 1.758157114111141084e+01 0.000000000000000000e+00 -1.934529290293457393e+01 2.051914136555176071e+01 0.000000000000000000e+00 -2.469945135601795982e+01 1.423525138722228434e+01 0.000000000000000000e+00 --5.173579843819545054e+00 1.281229603556361951e+01 0.000000000000000000e+00 -1.664254322942873898e+01 5.621903708588540383e-01 0.000000000000000000e+00 -2.190397159564632545e+01 4.786531971104349026e+00 0.000000000000000000e+00 -2.122469586625928883e+01 -3.435557448641041844e+00 0.000000000000000000e+00 -1.186206444106046121e+01 -3.923969442465372381e+00 0.000000000000000000e+00 --6.583504384934571796e+00 -3.646163095114181019e+00 0.000000000000000000e+00 --6.041641077230250900e-01 -3.866943441352347577e+00 0.000000000000000000e+00 -5.099911659274369846e+00 -4.987726757123468246e+00 0.000000000000000000e+00 --2.414919427809461006e+00 2.146494890127001298e+01 0.000000000000000000e+00 --7.659933184243787885e+00 8.061032475855579804e+00 0.000000000000000000e+00 -2.348782716477603394e+00 -2.050122490411958154e+00 0.000000000000000000e+00 --6.151041940423708887e+00 1.584878149000694236e+00 0.000000000000000000e+00 -8.138845415159547514e+00 -2.182609747632069386e+00 0.000000000000000000e+00 -1.387164168926463503e+01 -5.213894651485517784e-02 0.000000000000000000e+00 --1.623851995322669772e+00 -8.135123485823394063e+00 0.000000000000000000e+00 -2.120843233183418164e+01 2.262153377133245158e+00 0.000000000000000000e+00 -2.401557612521639129e+01 1.092558540406011858e+01 0.000000000000000000e+00 -1.541060449406165134e+01 -8.975620794331195640e+00 0.000000000000000000e+00 +-6.166402510069512566e+00 -3.400181940646167078e+00 0.000000000000000000e+00 +1.680063537447632704e+00 -6.714195732830342322e+00 0.000000000000000000e+00 +1.732465932699430411e+01 -3.928855518028747440e+00 0.000000000000000000e+00 +8.671988285036906774e+00 1.877668661267915695e+01 0.000000000000000000e+00 +-6.135902128595364324e+00 1.853196772134857184e+01 0.000000000000000000e+00 +2.390948701115297581e+01 3.296135462074222033e+00 0.000000000000000000e+00 +4.055888574998287588e+00 2.293825918097189032e+01 0.000000000000000000e+00 +2.091141785095403804e+01 1.839001170076179648e+01 0.000000000000000000e+00 +-1.829928731882941584e+00 2.302318570760571959e+01 0.000000000000000000e+00 +1.433017588985628521e+01 1.900851077954069268e+01 0.000000000000000000e+00 +1.942289416435973592e+01 2.514760323228420447e+01 0.000000000000000000e+00 +-6.687965029734099787e-01 -5.997943043653052086e+00 0.000000000000000000e+00 +-6.162962741241577724e+00 -6.246295455228789706e-01 0.000000000000000000e+00 +1.618062410303775067e+01 -5.773012113861710759e-01 0.000000000000000000e+00 +-9.129097064714997600e+00 5.735012370046149499e+00 0.000000000000000000e+00 +-4.559348473777027344e+00 1.777962466029617872e+01 0.000000000000000000e+00 +1.876506852173380935e+01 4.806496571613685376e+00 0.000000000000000000e+00 +4.402504280646561519e+00 -2.989543818100049322e+00 0.000000000000000000e+00 +2.452183258469225535e+01 -1.333378138939846025e+00 0.000000000000000000e+00 +1.918208781376934624e+01 -6.663948118629839712e+00 0.000000000000000000e+00 +2.090805684546805310e+01 1.294111048637202899e+01 0.000000000000000000e+00 +2.183463086014797483e+01 2.050166071122497158e+01 0.000000000000000000e+00 +5.412848552614545561e+00 -5.506383836929110487e+00 0.000000000000000000e+00 +-2.672273828039730681e+00 -5.443187738395502961e+00 0.000000000000000000e+00 +1.460674832180023586e+01 -4.707562517960768744e+00 0.000000000000000000e+00 +1.378597063920397048e-01 9.255492763157349145e-01 0.000000000000000000e+00 +1.547300827244687937e+01 4.016937826984531057e+00 0.000000000000000000e+00 +-5.524019554717077618e+00 1.883702862978137205e+01 0.000000000000000000e+00 +-4.934332883210072573e+00 4.430135266798423288e+00 0.000000000000000000e+00 +2.134978167448144859e+01 -3.844539638127034920e+00 0.000000000000000000e+00 +2.424711408203639706e+01 5.026586133645754018e+00 0.000000000000000000e+00 +1.678875707638681192e+01 1.856979563812782885e+01 0.000000000000000000e+00 +2.652247332604530072e+01 -1.434317248774881648e+00 0.000000000000000000e+00 +2.289388419865368007e+01 1.372048449029282224e+01 0.000000000000000000e+00 +2.393787535979383563e+01 3.979578988474230528e-02 0.000000000000000000e+00 +1.827803751983765324e+01 -7.259204021883764568e+00 0.000000000000000000e+00 +1.287377484585636012e+01 -8.964174660284813356e+00 0.000000000000000000e+00 +1.543709454460323016e+01 3.787352447014029622e-01 0.000000000000000000e+00 +8.956142015445561100e+00 -4.441241792612713013e+00 0.000000000000000000e+00 +2.097583429736967275e+01 1.382747990309472996e+01 0.000000000000000000e+00 +3.573168375845050981e+00 -6.463710089622745514e+00 0.000000000000000000e+00 +2.553195857278628011e+01 1.809110008785097534e+01 0.000000000000000000e+00 +2.071932502400398945e+01 2.334683697115575995e+01 0.000000000000000000e+00 +-5.727822098506435644e+00 6.409199771536844281e+00 0.000000000000000000e+00 +2.093705692537834118e+00 2.342715813221634846e+01 0.000000000000000000e+00 +-3.578699149715258265e+00 1.998402147733314393e+01 0.000000000000000000e+00 +1.803459869104751689e+01 -3.037801015509733915e+00 0.000000000000000000e+00 +1.634137666495451313e+01 -9.006097179027179322e+00 0.000000000000000000e+00 +3.388842666856839436e+00 -1.994043288179305762e+00 0.000000000000000000e+00 +2.229456148939334525e+01 1.623248886137080405e+00 0.000000000000000000e+00 +9.876693561099372687e+00 -1.739031218238730858e+00 0.000000000000000000e+00 +2.253871784207571949e+01 1.495298517716176434e+01 0.000000000000000000e+00 +5.784005152912432557e+00 -8.969417460110902240e+00 0.000000000000000000e+00 +-4.820654946208644098e+00 8.795343169667940941e+00 0.000000000000000000e+00 +-2.628175250526571638e+00 1.253579434818064442e+00 0.000000000000000000e+00 +-6.733452314260623517e+00 1.657770902124860157e+01 0.000000000000000000e+00 diff --git a/aquapointer/slicing.py b/aquapointer/slicing.py index 99f1955..e96fefe 100644 --- a/aquapointer/slicing.py +++ b/aquapointer/slicing.py @@ -56,27 +56,24 @@ def density_slices_by_planes( origin = density_origin(density_grid) endpoint = density_point_boundaries(density_grid) + + a = np.zeros_like(normals[0]) + a[normals[0].argmax()] = 1 + b = np.zeros_like(normals[-1]) + b[normals[-1].argmax()] = 1 midplane_points = ( - [(origin + slicing_planes[0][0, :]) / 2] - + [ - (slicing_planes[s][0, :] + slicing_planes[s + 1][0, :]) / 2 + [_calculate_midplane_points(a, normals[0], origin, slicing_planes[0][0,:])] + + [_calculate_midplane_points(normals[s], normals[s+1], slicing_planes[s][0,:], slicing_planes[s+1][0,:]) for s in range(len(slicing_planes) - 1) ] - + [ - slicing_planes[-1][0, :] - + normals[-1][1] - * (endpoint - slicing_planes[-1][0, :]).dot(normals[-1][1]) - / 2 - ] + + [_calculate_midplane_points(normals[-1], b, slicing_planes[-1][0, :], endpoint)] ) midplane_normals = ( - [normals[0]] - + [ - np.mean(np.array(normals[n : n + 2]), axis=0) - / norm(np.mean(np.array(normals[n : n + 2]), axis=0)) + [_calculate_midplane_normals(a, normals[0])] + + [_calculate_midplane_normals(normals[n], normals[n+1]) for n in range(len(normals) - 1) ] - + [normals[-1]] + + [_calculate_midplane_normals(normals[-1], b)] ) for ind in np.ndindex(density_grid.grid.shape): @@ -106,15 +103,6 @@ def density_slices_by_planes( break idx_lists[s].append(ind) - if s == 0: - a = origin - b = slicing_planes[s][0, :] - elif 0 < s < len(slicing_planes): - a = slicing_planes[s - 1][0, :] - b = slicing_planes[s][0, :] - else: - a = slicing_planes[s - 1][0, :] - b = endpoint point_lists[s].append( center @@ -139,6 +127,26 @@ def density_slices_by_planes( return density_canvases +def _calculate_midplane_points(n1, n2, p1, p2): + if n1[0] + n2[0]: + px = (n1[0] * p1[0] + n2[0] * p2[0]) / (n1[0] + n2[0]) + else: + px = 0 + if n1[1] + n2[1]: + py = (n1[1] * p1[1] + n2[1] * p2[1]) / (n1[1] + n2[1]) + else: + py = 0 + if n1[2] + n2[2]: + pz = (n1[2] * p1[2] + n2[2] * p2[2]) / (n1[2] + n2[2]) + else: + pz = 0 + return np.array([px, py, pz]) + + +def _calculate_midplane_normals(n1, n2): + return np.sum(np.array([n1, n2]), axis=0) / norm(np.sum(np.array([n1, n2]), axis=0)) + + def _generate_slice_rotation_matrix(normal: NDArray): n = np.cross(np.array([0, 0, 1]), normal) n1 = n[0]