Quaternions: another package

This commit is contained in:
L-Nafaryus 2021-03-30 22:14:47 +05:00
parent 9066dff9c2
commit e593583f26
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
2 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,7 @@
from collections import namedtuple
import os, sys
import logging
from pyquaternion import Quaternion
ROOT = "/home/nafaryus/projects/anisotrope-cube"
sys.path.append(ROOT)
@ -33,6 +34,17 @@ def genMesh(stype, theta, flowdirection, saveto):
geometry = geometry2
norm = [-1, -1, 1]
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])
#else:

View File

@ -7,7 +7,7 @@ geompy = geomBuilder.New()
import math
import logging
import quaternion
from pyquaternion import Quaternion
import numpy as np
@ -43,8 +43,8 @@ def createGroup(gobj, planelist, grains, name):
def createBoundary(gobj, bcount, dvec, norm, grains):
direction = np.quaternion(0, dvec[0], dvec[1], dvec[2]).normalized()
ax = lambda alpha: np.quaternion(
direction = Quaternion(0, dvec[0], dvec[1], dvec[2]).normalized
ax = lambda alpha: Quaternion(
np.cos(alpha * 0.5),
np.sin(alpha * 0.5) * norm[0],
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
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(
@ -62,7 +62,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains):
symvec = []
for qvec in vecs:
vec = qvec.vec
vec = qvec.vector
symvec.append(geompy.MakeVector(
geompy.MakeVertex(0, 0, 0),
geompy.MakeVertex(vec[0], vec[1], vec[2])))