Skip to content

Instantly share code, notes, and snippets.

@Onefabis
Created April 18, 2018 14:54
Show Gist options
  • Save Onefabis/4ecfa8af4c40f233060af3daf6ea71e7 to your computer and use it in GitHub Desktop.
Save Onefabis/4ecfa8af4c40f233060af3daf6ea71e7 to your computer and use it in GitHub Desktop.
import math
from mpmath import *
def euclidean_distance(p1, p2):
return math.sqrt(sum([(a - b) ** 2 for a, b in zip(p1, p2)]))
p1 = ( -1.0, 0.0, 1.0 )
p2 = ( 1.0, 0.0, -1.0 )
p3 = ( 1.0, 0.0, 1.0 )
r1 = [ 90.0, 0.0, 0.0 ]
r2 = [ 0.0, 90.0, 0.0 ]
r3 = [ 0.0, 0.0, 90.0 ]
points = [ p1, p2, p3 ]
rotations = [ r1, r2, r3 ]
trMatrix = []
roMatrix = []
blendVal = [ -0.5, 0.0, 0.5 ]
for p in points:
vals = [ euclidean_distance(p, x) for x in points ]
trMatrix.append( vals )
for r in rotations:
roMatrix.append( r )
resultsM = []
for l in xrange( len( rotations ) ):
resultsM.append( lu_solve( matrix(trMatrix),matrix(rotations[l]) ) )
for x in xrange( len(resultsM) ):
print [ resultsM[x][m] for m in range( len(resultsM) )]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment