Quaternions: another package
This commit is contained in:
parent
9066dff9c2
commit
e593583f26
@ -1,6 +1,7 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import os, sys
|
import os, sys
|
||||||
import logging
|
import logging
|
||||||
|
from pyquaternion import Quaternion
|
||||||
|
|
||||||
ROOT = "/home/nafaryus/projects/anisotrope-cube"
|
ROOT = "/home/nafaryus/projects/anisotrope-cube"
|
||||||
sys.path.append(ROOT)
|
sys.path.append(ROOT)
|
||||||
@ -33,6 +34,17 @@ def genMesh(stype, theta, flowdirection, saveto):
|
|||||||
geometry = geometry2
|
geometry = geometry2
|
||||||
norm = [-1, -1, 1]
|
norm = [-1, -1, 1]
|
||||||
bcount = 6
|
bcount = 6
|
||||||
|
|
||||||
|
# initial angle
|
||||||
|
angle = math.pi / 6
|
||||||
|
vec = Quaternion(0, flowdirection[0], flowdirection[1], flowdirection[2])
|
||||||
|
ax = Quaternion(
|
||||||
|
math.cos(angle * 0.5),
|
||||||
|
math.sin(angle * 0.5) * norm[0],
|
||||||
|
math.sin(angle * 0.5) * norm[1],
|
||||||
|
math.sin(angle * 0.5) * norm[2])
|
||||||
|
qvec = (ax * vec * ax.inverse).vector
|
||||||
|
norm = [qvec[0], qvec[1], qvec[2]]
|
||||||
#direction = fd([1, 1, 1], [1, -1, 1], [1, -1, -1])
|
#direction = fd([1, 1, 1], [1, -1, 1], [1, -1, -1])
|
||||||
|
|
||||||
#else:
|
#else:
|
||||||
|
@ -7,7 +7,7 @@ geompy = geomBuilder.New()
|
|||||||
|
|
||||||
import math
|
import math
|
||||||
import logging
|
import logging
|
||||||
import quaternion
|
from pyquaternion import Quaternion
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ def createGroup(gobj, planelist, grains, name):
|
|||||||
|
|
||||||
def createBoundary(gobj, bcount, dvec, norm, grains):
|
def createBoundary(gobj, bcount, dvec, norm, grains):
|
||||||
|
|
||||||
direction = np.quaternion(0, dvec[0], dvec[1], dvec[2]).normalized()
|
direction = Quaternion(0, dvec[0], dvec[1], dvec[2]).normalized
|
||||||
ax = lambda alpha: np.quaternion(
|
ax = lambda alpha: Quaternion(
|
||||||
np.cos(alpha * 0.5),
|
np.cos(alpha * 0.5),
|
||||||
np.sin(alpha * 0.5) * norm[0],
|
np.sin(alpha * 0.5) * norm[0],
|
||||||
np.sin(alpha * 0.5) * norm[1],
|
np.sin(alpha * 0.5) * norm[1],
|
||||||
@ -53,7 +53,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains):
|
|||||||
ang = lambda n, count: 2 * np.pi * n / count
|
ang = lambda n, count: 2 * np.pi * n / count
|
||||||
limit = bcount if np.mod(bcount, 2) else int(bcount / 2)
|
limit = bcount if np.mod(bcount, 2) else int(bcount / 2)
|
||||||
|
|
||||||
vecs = [ ax(ang(n, bcount)) * direction * ax(ang(n, bcount)).inverse() for n in range(limit) ]
|
vecs = [ ax(ang(n, bcount)) * direction * ax(ang(n, bcount)).inverse for n in range(limit) ]
|
||||||
|
|
||||||
#
|
#
|
||||||
flowvec = geompy.MakeVector(
|
flowvec = geompy.MakeVector(
|
||||||
@ -62,7 +62,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains):
|
|||||||
symvec = []
|
symvec = []
|
||||||
|
|
||||||
for qvec in vecs:
|
for qvec in vecs:
|
||||||
vec = qvec.vec
|
vec = qvec.vector
|
||||||
symvec.append(geompy.MakeVector(
|
symvec.append(geompy.MakeVector(
|
||||||
geompy.MakeVertex(0, 0, 0),
|
geompy.MakeVertex(0, 0, 0),
|
||||||
geompy.MakeVertex(vec[0], vec[1], vec[2])))
|
geompy.MakeVertex(vec[0], vec[1], vec[2])))
|
||||||
|
Loading…
Reference in New Issue
Block a user